diff options
| author | Valentin Anger <syrupthinker@gryphno.de> | 2020-01-29 13:22:11 +0100 |
|---|---|---|
| committer | Andrew Kelley <andrew@ziglang.org> | 2020-01-29 16:09:07 -0500 |
| commit | d448c3d38af9f8f70daaa2817a5834e30da4b8ca (patch) | |
| tree | 647e1885ea02bbe9557338d0edb818f17abaae21 /lib/std | |
| parent | 59bc1d272120bd860cc3cd1f894a2a4e08fc1f3f (diff) | |
| download | zig-d448c3d38af9f8f70daaa2817a5834e30da4b8ca.tar.gz zig-d448c3d38af9f8f70daaa2817a5834e30da4b8ca.zip | |
Add support for code model selection
Diffstat (limited to 'lib/std')
| -rw-r--r-- | lib/std/build.zig | 6 | ||||
| -rw-r--r-- | lib/std/builtin.zig | 15 |
2 files changed, 21 insertions, 0 deletions
diff --git a/lib/std/build.zig b/lib/std/build.zig index d310f53c06..f535b022af 100644 --- a/lib/std/build.zig +++ b/lib/std/build.zig @@ -1149,6 +1149,7 @@ pub const LibExeObjStep = struct { name_prefix: []const u8, filter: ?[]const u8, single_threaded: bool, + code_model: builtin.CodeModel = .default, root_src: ?FileSource, out_h_filename: []const u8, @@ -1970,6 +1971,11 @@ pub const LibExeObjStep = struct { try zig_args.append("-fno-sanitize-c"); } + if (self.code_model != .default) { + try zig_args.append("-code-model"); + try zig_args.append(@tagName(self.code_model)); + } + switch (self.target) { .Native => {}, .Cross => |cross| { diff --git a/lib/std/builtin.zig b/lib/std/builtin.zig index d65b9b08ee..d8f24753d3 100644 --- a/lib/std/builtin.zig +++ b/lib/std/builtin.zig @@ -91,6 +91,21 @@ pub const AtomicRmwOp = enum { Min, }; +/// The code model puts constraints on the location of symbols and the size of code and data. +/// The selection of a code model is a trade off on speed and restrictions that needs to be selected on a per application basis to meet its requirements. +/// A slightly more detailed explanation can be found in (for example) the [System V Application Binary Interface (x86_64)](https://github.com/hjl-tools/x86-psABI/wiki/x86-64-psABI-1.0.pdf) 3.5.1. +/// +/// This data structure is used by the Zig language code generation and +/// therefore must be kept in sync with the compiler implementation. +pub const CodeModel = enum { + default, + tiny, + small, + kernel, + medium, + large, +}; + /// This data structure is used by the Zig language code generation and /// therefore must be kept in sync with the compiler implementation. pub const Mode = enum { |
