authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2023-08-02 21:49:26-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2023-08-03 09:52:15-07:00
log4089f96defa7dae169e2b6cdba5e545293e57cb8
treeaa5113504d95d1cb94a993e76bce05d0db01d64a
parent9dd9aa49a59cf8534aaf9b44ee20d526ba8da1c6

darwin: pass -iframework to clang for system frameworks


2 files changed, 22 insertions(+), 6 deletions(-)

src/Compilation.zig+20-1
......@@ -124,6 +124,7 @@ zig_lib_directory: Directory,
124124local_cache_directory: Directory,
125125global_cache_directory: Directory,
126126libc_include_dir_list: []const []const u8,
127libc_framework_dir_list: []const []const u8,
127128thread_pool: *ThreadPool,
128129
129130/// Populated when we build the libc++ static library. A Job to build this is placed in the queue
......@@ -1593,6 +1594,7 @@ pub fn create(gpa: Allocator, options: InitOptions) !*Compilation {
15931594 .cache_parent = cache,
15941595 .self_exe_path = options.self_exe_path,
15951596 .libc_include_dir_list = libc_dirs.libc_include_dir_list,
1597 .libc_framework_dir_list = libc_dirs.libc_framework_dir_list,
15961598 .sanitize_c = sanitize_c,
15971599 .thread_pool = options.thread_pool,
15981600 .clang_passthrough_mode = options.clang_passthrough_mode,
......@@ -4335,8 +4337,12 @@ pub fn addCCArgs(
43354337 try argv.append("-ObjC++");
43364338 }
43374339
4340 for (comp.libc_framework_dir_list) |framework_dir| {
4341 try argv.appendSlice(&.{ "-iframework", framework_dir });
4342 }
4343
43384344 for (comp.bin_file.options.framework_dirs) |framework_dir| {
4339 try argv.appendSlice(&.{ "-isystem", framework_dir });
4345 try argv.appendSlice(&.{ "-F", framework_dir });
43404346 }
43414347
43424348 // According to Rich Felker libc headers are supposed to go before C language headers.
......@@ -4821,6 +4827,7 @@ test "classifyFileExt" {
48214827const LibCDirs = struct {
48224828 libc_include_dir_list: []const []const u8,
48234829 libc_installation: ?*const LibCInstallation,
4830 libc_framework_dir_list: []const []const u8,
48244831};
48254832
48264833fn getZigShippedLibCIncludeDirsDarwin(arena: Allocator, zig_lib_dir: []const u8, target: Target) !LibCDirs {
......@@ -4851,6 +4858,7 @@ fn getZigShippedLibCIncludeDirsDarwin(arena: Allocator, zig_lib_dir: []const u8,
48514858 return LibCDirs{
48524859 .libc_include_dir_list = list,
48534860 .libc_installation = null,
4861 .libc_framework_dir_list = &.{},
48544862 };
48554863}
48564864
......@@ -4866,6 +4874,7 @@ fn detectLibCIncludeDirs(
48664874 return LibCDirs{
48674875 .libc_include_dir_list = &[0][]u8{},
48684876 .libc_installation = null,
4877 .libc_framework_dir_list = &.{},
48694878 };
48704879 }
48714880
......@@ -4921,11 +4930,13 @@ fn detectLibCIncludeDirs(
49214930 return LibCDirs{
49224931 .libc_include_dir_list = &[0][]u8{},
49234932 .libc_installation = null,
4933 .libc_framework_dir_list = &.{},
49244934 };
49254935}
49264936
49274937fn detectLibCFromLibCInstallation(arena: Allocator, target: Target, lci: *const LibCInstallation) !LibCDirs {
49284938 var list = try std.ArrayList([]const u8).initCapacity(arena, 5);
4939 var framework_list = std.ArrayList([]const u8).init(arena);
49294940
49304941 list.appendAssumeCapacity(lci.include_dir.?);
49314942
......@@ -4953,9 +4964,16 @@ fn detectLibCFromLibCInstallation(arena: Allocator, target: Target, lci: *const
49534964 list.appendAssumeCapacity(config_dir);
49544965 }
49554966
4967 if (target.isDarwin()) d: {
4968 const down1 = std.fs.path.dirname(lci.sys_include_dir.?) orelse break :d;
4969 const down2 = std.fs.path.dirname(down1) orelse break :d;
4970 try framework_list.append(try std.fs.path.join(arena, &.{ down2, "System", "Library", "Frameworks" }));
4971 }
4972
49564973 return LibCDirs{
49574974 .libc_include_dir_list = list.items,
49584975 .libc_installation = lci,
4976 .libc_framework_dir_list = framework_list.items,
49594977 };
49604978}
49614979
......@@ -5015,6 +5033,7 @@ fn detectLibCFromBuilding(
50155033 return LibCDirs{
50165034 .libc_include_dir_list = list,
50175035 .libc_installation = null,
5036 .libc_framework_dir_list = &.{},
50185037 };
50195038}
50205039
src/main.zig+2-5
......@@ -2695,11 +2695,8 @@ fn buildOutputType(
26952695 try rpath_list.appendSlice(paths.rpaths.items);
26962696 }
26972697
2698 // Now that we have target info, we can find out if any of the system libraries
2699 // are part of libc or libc++. We remove them from the list and communicate their
2700 // existence via flags instead.
2701 // Similarly, if any libs in this list are statically provided, we omit
2702 // them from the resolved list and populate the link_objects array instead.
2698 // If any libs in this list are statically provided, we omit them from the
2699 // resolved list and populate the link_objects array instead.
27032700 {
27042701 var test_path = std.ArrayList(u8).init(gpa);
27052702 defer test_path.deinit();