| author | |
| committer | |
| log | 7688100b1770a7d688348b8f31282c3a6a69e9f9 |
| tree | 275a30275dea55527cecd32a827b2c719db28196 |
| parent | 15471531d04f404b9327b28bd4e592ba3cd9ac2f |
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 { | ... | @@ -373,6 +373,7 @@ fn addLibUserlandStep(b: *Builder, mode: builtin.Mode) void { |
| 373 | artifact.bundle_compiler_rt = true; | 373 | artifact.bundle_compiler_rt = true; |
| 374 | artifact.setTarget(builtin.arch, builtin.os, builtin.abi); | 374 | artifact.setTarget(builtin.arch, builtin.os, builtin.abi); |
| 375 | artifact.setBuildMode(mode); | 375 | artifact.setBuildMode(mode); |
| 376 | artifact.force_pic = true; | ||
| 376 | if (mode != .Debug) { | 377 | if (mode != .Debug) { |
| 377 | artifact.strip = true; | 378 | artifact.strip = true; |
| 378 | } | 379 | } |
lib/std/build.zig+11| ... | @@ -1488,6 +1488,9 @@ pub const LibExeObjStep = struct { | ... | @@ -1488,6 +1488,9 @@ pub const LibExeObjStep = struct { |
| 1488 | 1488 | ||
| 1489 | dynamic_linker: ?[]const u8 = null, | 1489 | dynamic_linker: ?[]const u8 = null, |
| 1490 | 1490 | ||
| 1491 | /// Position Independent Code | ||
| 1492 | force_pic: ?bool = null, | ||
| 1493 | |||
| 1491 | const LinkObject = union(enum) { | 1494 | const LinkObject = union(enum) { |
| 1492 | StaticPath: []const u8, | 1495 | StaticPath: []const u8, |
| 1493 | OtherStep: *LibExeObjStep, | 1496 | OtherStep: *LibExeObjStep, |
| ... | @@ -2314,6 +2317,14 @@ pub const LibExeObjStep = struct { | ... | @@ -2314,6 +2317,14 @@ pub const LibExeObjStep = struct { |
| 2314 | try zig_args.append(builder.pathFromRoot(dir)); | 2317 | try zig_args.append(builder.pathFromRoot(dir)); |
| 2315 | } | 2318 | } |
| 2316 | 2319 | ||
| 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 | |||
| 2317 | if (self.kind == Kind.Test) { | 2328 | if (self.kind == Kind.Test) { |
| 2318 | try builder.spawnChild(zig_args.toSliceConst()); | 2329 | try builder.spawnChild(zig_args.toSliceConst()); |
| 2319 | } else { | 2330 | } else { |