mirror of
https://github.com/ziglang/zig.git
synced 2026-02-21 08:45:52 +00:00
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.
This commit is contained in:
parent
15471531d0
commit
7688100b17
@ -373,6 +373,7 @@ fn addLibUserlandStep(b: *Builder, mode: builtin.Mode) void {
|
||||
artifact.bundle_compiler_rt = true;
|
||||
artifact.setTarget(builtin.arch, builtin.os, builtin.abi);
|
||||
artifact.setBuildMode(mode);
|
||||
artifact.force_pic = true;
|
||||
if (mode != .Debug) {
|
||||
artifact.strip = true;
|
||||
}
|
||||
|
||||
@ -1488,6 +1488,9 @@ pub const LibExeObjStep = struct {
|
||||
|
||||
dynamic_linker: ?[]const u8 = null,
|
||||
|
||||
/// Position Independent Code
|
||||
force_pic: ?bool = null,
|
||||
|
||||
const LinkObject = union(enum) {
|
||||
StaticPath: []const u8,
|
||||
OtherStep: *LibExeObjStep,
|
||||
@ -2314,6 +2317,14 @@ pub const LibExeObjStep = struct {
|
||||
try zig_args.append(builder.pathFromRoot(dir));
|
||||
}
|
||||
|
||||
if (self.force_pic) |pic| {
|
||||
if (pic) {
|
||||
try zig_args.append("-fPIC");
|
||||
} else {
|
||||
try zig_args.append("-fno-PIC");
|
||||
}
|
||||
}
|
||||
|
||||
if (self.kind == Kind.Test) {
|
||||
try builder.spawnChild(zig_args.toSliceConst());
|
||||
} else {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user