From f0ddc7f7a2e2fba2515dfb4f3ad06ea56646eba7 Mon Sep 17 00:00:00 2001 From: Andrew Kelley Date: Tue, 25 Jan 2022 22:01:22 -0700 Subject: 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. --- src/Compilation.zig | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src/Compilation.zig') 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 => { -- cgit v1.2.3