aboutsummaryrefslogtreecommitdiff
path: root/src/Compilation.zig
diff options
context:
space:
mode:
authorMotiejus Jakštys <motiejus@jakstys.lt>2022-06-16 15:42:35 +0300
committerJakub Konka <kubkon@jakubkonka.com>2022-06-20 13:39:33 +0200
commit98138ba78c1540830a4fdb0537ed6ad5c7b57e7a (patch)
tree8ff0a80295d0702fbe63bf8849c4b390ba94bd50 /src/Compilation.zig
parenta97a39bea6022fb7449620384641cdfa70303f8d (diff)
downloadzig-98138ba78c1540830a4fdb0537ed6ad5c7b57e7a.tar.gz
zig-98138ba78c1540830a4fdb0537ed6ad5c7b57e7a.zip
[MachO] add -pagezero_size
Pass `-pagezero_size` to the MachO linker. This is the final "unsupported linker arg" that I could chase that CGo uses. After this and #11874 we may be able to fail on an "unsupported linker arg" instead of emiting a warning. Test case: zig=/code/zig/build/zig CGO_ENABLED=1 GOOS=darwin GOARCH=amd64 CC="$zig cc -target x86_64-macos" CXX="$zig c++ -target x86_64-macos" go build -a -ldflags "-s -w" cgo.go I compiled a trivial CGo program and executed it on an amd64 Darwin host. To be honest, I am not entirely sure what this is doing. This feels right after reading what this argument does in LLVM sources, but I am by no means qualified to make MachO pull requests. Will take feedback.
Diffstat (limited to 'src/Compilation.zig')
-rw-r--r--src/Compilation.zig7
1 files changed, 5 insertions, 2 deletions
diff --git a/src/Compilation.zig b/src/Compilation.zig
index 2646da2f6f..98d69ee78e 100644
--- a/src/Compilation.zig
+++ b/src/Compilation.zig
@@ -903,6 +903,8 @@ pub const InitOptions = struct {
install_name: ?[]const u8 = null,
/// (Darwin) Path to entitlements file
entitlements: ?[]const u8 = null,
+ /// (Darwin) size of the __PAGEZERO segment
+ pagezero_size: ?u64 = null,
};
fn addPackageTableToCacheHash(
@@ -2359,7 +2361,7 @@ fn prepareWholeEmitSubPath(arena: Allocator, opt_emit: ?EmitLoc) error{OutOfMemo
/// to remind the programmer to update multiple related pieces of code that
/// are in different locations. Bump this number when adding or deleting
/// anything from the link cache manifest.
-pub const link_hash_implementation_version = 3;
+pub const link_hash_implementation_version = 4;
fn addNonIncrementalStuffToCacheManifest(comp: *Compilation, man: *Cache.Manifest) !void {
const gpa = comp.gpa;
@@ -2369,7 +2371,7 @@ fn addNonIncrementalStuffToCacheManifest(comp: *Compilation, man: *Cache.Manifes
defer arena_allocator.deinit();
const arena = arena_allocator.allocator();
- comptime assert(link_hash_implementation_version == 3);
+ comptime assert(link_hash_implementation_version == 4);
if (comp.bin_file.options.module) |mod| {
const main_zig_file = try mod.main_pkg.root_src_directory.join(arena, &[_][]const u8{
@@ -2474,6 +2476,7 @@ fn addNonIncrementalStuffToCacheManifest(comp: *Compilation, man: *Cache.Manifes
man.hash.addListOfBytes(comp.bin_file.options.framework_dirs);
man.hash.addListOfBytes(comp.bin_file.options.frameworks);
try man.addOptionalFile(comp.bin_file.options.entitlements);
+ if (comp.bin_file.options.pagezero_size) |value| man.hash.add(value);
// COFF specific stuff
man.hash.addOptional(comp.bin_file.options.subsystem);