authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2019-10-07 17:22:28-04:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2019-10-08 00:06:28-04:00
log7688100b1770a7d688348b8f31282c3a6a69e9f9
tree275a30275dea55527cecd32a827b2c719db28196
parent15471531d04f404b9327b28bd4e592ba3cd9ac2f

stage1: enable PIC for libuserland

we don't really have a way to determine whether the stage1 zig compiler requires PIC so to be safe we always enable it when building libuserland. fixes build on some configurations of alpine linux.

2 files changed, 12 insertions(+), 0 deletions(-)

build.zig+1
......@@ -373,6 +373,7 @@ fn addLibUserlandStep(b: *Builder, mode: builtin.Mode) void {
373373 artifact.bundle_compiler_rt = true;
374374 artifact.setTarget(builtin.arch, builtin.os, builtin.abi);
375375 artifact.setBuildMode(mode);
376 artifact.force_pic = true;
376377 if (mode != .Debug) {
377378 artifact.strip = true;
378379 }
lib/std/build.zig+11
......@@ -1488,6 +1488,9 @@ pub const LibExeObjStep = struct {
14881488
14891489 dynamic_linker: ?[]const u8 = null,
14901490
1491 /// Position Independent Code
1492 force_pic: ?bool = null,
1493
14911494 const LinkObject = union(enum) {
14921495 StaticPath: []const u8,
14931496 OtherStep: *LibExeObjStep,
......@@ -2314,6 +2317,14 @@ pub const LibExeObjStep = struct {
23142317 try zig_args.append(builder.pathFromRoot(dir));
23152318 }
23162319
2320 if (self.force_pic) |pic| {
2321 if (pic) {
2322 try zig_args.append("-fPIC");
2323 } else {
2324 try zig_args.append("-fno-PIC");
2325 }
2326 }
2327
23172328 if (self.kind == Kind.Test) {
23182329 try builder.spawnChild(zig_args.toSliceConst());
23192330 } else {