From 33b542152876b9ccbf42cc3d070d582c32145477 Mon Sep 17 00:00:00 2001 From: khyperia Date: Fri, 27 Dec 2024 23:03:58 +0100 Subject: [PATCH 1/3] Add -fuse-lipo option --- clang/include/clang/Driver/Options.td | 1 + clang/lib/Driver/ToolChains/Darwin.cpp | 5 ++++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/clang/include/clang/Driver/Options.td b/clang/include/clang/Driver/Options.td index d922709db17786..6cd23de87bacde 100644 --- a/clang/include/clang/Driver/Options.td +++ b/clang/include/clang/Driver/Options.td @@ -6654,6 +6654,7 @@ def fbinutils_version_EQ : Joined<["-"], "fbinutils-version=">, def fuse_ld_EQ : Joined<["-"], "fuse-ld=">, Group, Flags<[LinkOption]>, Visibility<[ClangOption, FlangOption, CLOption]>; def ld_path_EQ : Joined<["--"], "ld-path=">, Group; +def fuse_lipo_EQ : Joined<["-"], "fuse-lipo=">, Group, Flags<[LinkOption]>; defm align_labels : BooleanFFlag<"align-labels">, Group; def falign_labels_EQ : Joined<["-"], "falign-labels=">, Group; diff --git a/clang/lib/Driver/ToolChains/Darwin.cpp b/clang/lib/Driver/ToolChains/Darwin.cpp index 4105d38d15d7d8..0d3cbb57362164 100644 --- a/clang/lib/Driver/ToolChains/Darwin.cpp +++ b/clang/lib/Driver/ToolChains/Darwin.cpp @@ -910,7 +910,10 @@ void darwin::Lipo::ConstructJob(Compilation &C, const JobAction &JA, CmdArgs.push_back(II.getFilename()); } - const char *Exec = Args.MakeArgString(getToolChain().GetProgramPath("lipo")); + std::string LipoName = + std::string(Args.getLastArgValue(options::OPT_fuse_lipo_EQ, "lipo")); + const char *Exec = + Args.MakeArgString(getToolChain().GetProgramPath(LipoName.c_str())); C.addCommand(std::make_unique(JA, *this, ResponseFileSupport::None(), Exec, CmdArgs, Inputs, Output)); } From fed315be5a6b2b5d898f92872782ec5f85dd8215 Mon Sep 17 00:00:00 2001 From: khyperia Date: Sat, 28 Dec 2024 11:11:35 +0100 Subject: [PATCH 2/3] Add basic fuse-lipo.c tests --- clang/lib/Driver/ToolChains/Darwin.cpp | 5 ++--- clang/test/Driver/fuse-lipo.c | 11 +++++++++++ 2 files changed, 13 insertions(+), 3 deletions(-) create mode 100644 clang/test/Driver/fuse-lipo.c diff --git a/clang/lib/Driver/ToolChains/Darwin.cpp b/clang/lib/Driver/ToolChains/Darwin.cpp index 0d3cbb57362164..e5f28fd0a49124 100644 --- a/clang/lib/Driver/ToolChains/Darwin.cpp +++ b/clang/lib/Driver/ToolChains/Darwin.cpp @@ -910,10 +910,9 @@ void darwin::Lipo::ConstructJob(Compilation &C, const JobAction &JA, CmdArgs.push_back(II.getFilename()); } - std::string LipoName = - std::string(Args.getLastArgValue(options::OPT_fuse_lipo_EQ, "lipo")); + StringRef LipoName = Args.getLastArgValue(options::OPT_fuse_lipo_EQ, "lipo"); const char *Exec = - Args.MakeArgString(getToolChain().GetProgramPath(LipoName.c_str())); + Args.MakeArgString(getToolChain().GetProgramPath(LipoName.data())); C.addCommand(std::make_unique(JA, *this, ResponseFileSupport::None(), Exec, CmdArgs, Inputs, Output)); } diff --git a/clang/test/Driver/fuse-lipo.c b/clang/test/Driver/fuse-lipo.c new file mode 100644 index 00000000000000..2cf478482be03f --- /dev/null +++ b/clang/test/Driver/fuse-lipo.c @@ -0,0 +1,11 @@ +// RUN: %clang %s -### --target=arm64-apple-darwin -arch x86_64 -arch arm64 -fuse-lipo=llvm-lipo 2>&1 | FileCheck -check-prefix=TEST1 %s +// TEST1: llvm-lipo + +// RUN: %clang %s -### --target=arm64-apple-darwin -arch x86_64 -arch arm64 -fuse-lipo=nonexistant-lipo 2>&1 | FileCheck -check-prefix=TEST2 %s +// TEST2: nonexistant-lipo + +// RUN: %clang %s -### --target=arm64-apple-darwin -fuse-lipo=llvm-lipo 2>&1 | FileCheck -check-prefix=TEST3 %s +// TEST3: clang: warning: argument unused during compilation: '-fuse-lipo=llvm-lipo' + +// RUN: %clang %s -### --target=arm64-apple-darwin -Wno-unused-command-line-argument -fuse-lipo=llvm-lipo 2>&1 | FileCheck -check-prefix=TEST4 %s +// TEST4-NOT: llvm-lipo From 1329e556cc84746c86ad3be4e592c09e557320cf Mon Sep 17 00:00:00 2001 From: khyperia Date: Thu, 2 Jan 2025 20:24:07 +0100 Subject: [PATCH 3/3] Add fuse-lipo test without arg --- clang/test/Driver/fuse-lipo.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/clang/test/Driver/fuse-lipo.c b/clang/test/Driver/fuse-lipo.c index 2cf478482be03f..2dedb86ddc527a 100644 --- a/clang/test/Driver/fuse-lipo.c +++ b/clang/test/Driver/fuse-lipo.c @@ -9,3 +9,7 @@ // RUN: %clang %s -### --target=arm64-apple-darwin -Wno-unused-command-line-argument -fuse-lipo=llvm-lipo 2>&1 | FileCheck -check-prefix=TEST4 %s // TEST4-NOT: llvm-lipo + +// RUN: %clang %s -### --target=arm64-apple-darwin -arch x86_64 -arch arm64 2>&1 | FileCheck -check-prefix=TEST5 %s +// TEST5: lipo +// TEST5-NOT: llvm-lipo