aboutsummaryrefslogtreecommitdiff
path: root/src/Compilation.zig
diff options
context:
space:
mode:
authorAndrew Kelley <andrew@ziglang.org>2022-01-25 22:01:22 -0700
committerAndrew Kelley <andrew@ziglang.org>2022-01-25 22:04:01 -0700
commitf0ddc7f7a2e2fba2515dfb4f3ad06ea56646eba7 (patch)
tree45f70c9e463de4113c1ac64ba689582736a260b9 /src/Compilation.zig
parent618055db50c5354a17f9eefc2cee77ec2de96f6a (diff)
downloadzig-f0ddc7f7a2e2fba2515dfb4f3ad06ea56646eba7.tar.gz
zig-f0ddc7f7a2e2fba2515dfb4f3ad06ea56646eba7.zip
translate-c: update for new function pointer semantics
After #10656, function pointers are represented with e.g. `*const fn()void` rather than `fn()void`. This commit adds code to translate-c to emit different code depending on whether the output zig source code is intended to be compiled with stage1 or stage2. Ideally we will have stage1 and stage2 support the exact same Zig language, but for now they diverge because I would rather focus on finishing and shipping stage2 than implementing the features in stage1.
Diffstat (limited to 'src/Compilation.zig')
-rw-r--r--src/Compilation.zig4
1 files changed, 4 insertions, 0 deletions
diff --git a/src/Compilation.zig b/src/Compilation.zig
index cffda8f36e..dec98ed781 100644
--- a/src/Compilation.zig
+++ b/src/Compilation.zig
@@ -3305,7 +3305,10 @@ pub fn cImport(comp: *Compilation, c_src: []const u8) !CImportResult {
var man = comp.obtainCObjectCacheManifest();
defer man.deinit();
+ const use_stage1 = build_options.is_stage1 and comp.bin_file.options.use_stage1;
+
man.hash.add(@as(u16, 0xb945)); // Random number to distinguish translate-c from compiling C objects
+ man.hash.add(use_stage1);
man.hash.addBytes(c_src);
// If the previous invocation resulted in clang errors, we will see a hit
@@ -3369,6 +3372,7 @@ pub fn cImport(comp: *Compilation, c_src: []const u8) !CImportResult {
new_argv.ptr + new_argv.len,
&clang_errors,
c_headers_dir_path_z,
+ use_stage1,
) catch |err| switch (err) {
error.OutOfMemory => return error.OutOfMemory,
error.ASTUnitFailure => {