| ... | ... | @@ -951,6 +951,7 @@ pub fn create(gpa: *Allocator, options: InitOptions) !*Compilation { |
| 951 | 951 | options.target, |
| 952 | 952 | options.is_native_abi, |
| 953 | 953 | link_libc, |
| 954 | options.system_libs.len != 0, |
| 954 | 955 | options.libc_installation, |
| 955 | 956 | ); |
| 956 | 957 | |
| ... | ... | @@ -3129,6 +3130,7 @@ fn detectLibCIncludeDirs( |
| 3129 | 3130 | target: Target, |
| 3130 | 3131 | is_native_abi: bool, |
| 3131 | 3132 | link_libc: bool, |
| 3133 | link_system_libs: bool, |
| 3132 | 3134 | libc_installation: ?*const LibCInstallation, |
| 3133 | 3135 | ) !LibCDirs { |
| 3134 | 3136 | if (!link_libc) { |
| ... | ... | @@ -3142,12 +3144,16 @@ fn detectLibCIncludeDirs( |
| 3142 | 3144 | return detectLibCFromLibCInstallation(arena, target, lci); |
| 3143 | 3145 | } |
| 3144 | 3146 | |
| 3145 | | if (is_native_abi) { |
| 3147 | // If linking system libraries and targeting the native abi, default to |
| 3148 | // using the system libc installation. |
| 3149 | if (link_system_libs and is_native_abi) { |
| 3146 | 3150 | const libc = try arena.create(LibCInstallation); |
| 3147 | 3151 | libc.* = try LibCInstallation.findNative(.{ .allocator = arena, .verbose = true }); |
| 3148 | 3152 | return detectLibCFromLibCInstallation(arena, target, libc); |
| 3149 | 3153 | } |
| 3150 | 3154 | |
| 3155 | // If not linking system libraries, build and provide our own libc by |
| 3156 | // default if possible. |
| 3151 | 3157 | if (target_util.canBuildLibC(target)) { |
| 3152 | 3158 | const generic_name = target_util.libCGenericName(target); |
| 3153 | 3159 | // Some architectures are handled by the same set of headers. |
| ... | ... | @@ -3198,6 +3204,14 @@ fn detectLibCIncludeDirs( |
| 3198 | 3204 | }; |
| 3199 | 3205 | } |
| 3200 | 3206 | |
| 3207 | // If zig can't build the libc for the target and we are targeting the |
| 3208 | // native abi, fall back to using the system libc installation. |
| 3209 | if (is_native_abi) { |
| 3210 | const libc = try arena.create(LibCInstallation); |
| 3211 | libc.* = try LibCInstallation.findNative(.{ .allocator = arena, .verbose = true }); |
| 3212 | return detectLibCFromLibCInstallation(arena, target, libc); |
| 3213 | } |
| 3214 | |
| 3201 | 3215 | return LibCDirs{ |
| 3202 | 3216 | .libc_include_dir_list = &[0][]u8{}, |
| 3203 | 3217 | .libc_installation = null, |