Skip to content

Commit 9be358f

Browse files
authored
[clang][Driver] Add -fuse-lipo option (#121231)
Partially fixes #59552 by adding a new option `-fuse-lipo` that can specify the tool name to be used by clang-driver for the lipo action. For example, pass `-fuse-lipo=llvm-lipo` to use `llvm-lipo` instead of the default `lipo`.
1 parent 840b94d commit 9be358f

File tree

3 files changed

+19
-1
lines changed

3 files changed

+19
-1
lines changed

clang/include/clang/Driver/Options.td

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6670,6 +6670,7 @@ def fbinutils_version_EQ : Joined<["-"], "fbinutils-version=">,
66706670
def fuse_ld_EQ : Joined<["-"], "fuse-ld=">, Group<f_Group>,
66716671
Flags<[LinkOption]>, Visibility<[ClangOption, FlangOption, CLOption]>;
66726672
def ld_path_EQ : Joined<["--"], "ld-path=">, Group<Link_Group>;
6673+
def fuse_lipo_EQ : Joined<["-"], "fuse-lipo=">, Group<f_clang_Group>, Flags<[LinkOption]>;
66736674

66746675
defm align_labels : BooleanFFlag<"align-labels">, Group<clang_ignored_gcc_optimization_f_Group>;
66756676
def falign_labels_EQ : Joined<["-"], "falign-labels=">, Group<clang_ignored_gcc_optimization_f_Group>;

clang/lib/Driver/ToolChains/Darwin.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -910,7 +910,9 @@ void darwin::Lipo::ConstructJob(Compilation &C, const JobAction &JA,
910910
CmdArgs.push_back(II.getFilename());
911911
}
912912

913-
const char *Exec = Args.MakeArgString(getToolChain().GetProgramPath("lipo"));
913+
StringRef LipoName = Args.getLastArgValue(options::OPT_fuse_lipo_EQ, "lipo");
914+
const char *Exec =
915+
Args.MakeArgString(getToolChain().GetProgramPath(LipoName.data()));
914916
C.addCommand(std::make_unique<Command>(JA, *this, ResponseFileSupport::None(),
915917
Exec, CmdArgs, Inputs, Output));
916918
}

clang/test/Driver/fuse-lipo.c

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// RUN: %clang %s -### --target=arm64-apple-darwin -arch x86_64 -arch arm64 -fuse-lipo=llvm-lipo 2>&1 | FileCheck -check-prefix=TEST1 %s
2+
// TEST1: llvm-lipo
3+
4+
// RUN: %clang %s -### --target=arm64-apple-darwin -arch x86_64 -arch arm64 -fuse-lipo=nonexistant-lipo 2>&1 | FileCheck -check-prefix=TEST2 %s
5+
// TEST2: nonexistant-lipo
6+
7+
// RUN: %clang %s -### --target=arm64-apple-darwin -fuse-lipo=llvm-lipo 2>&1 | FileCheck -check-prefix=TEST3 %s
8+
// TEST3: clang: warning: argument unused during compilation: '-fuse-lipo=llvm-lipo'
9+
10+
// RUN: %clang %s -### --target=arm64-apple-darwin -Wno-unused-command-line-argument -fuse-lipo=llvm-lipo 2>&1 | FileCheck -check-prefix=TEST4 %s
11+
// TEST4-NOT: llvm-lipo
12+
13+
// RUN: %clang %s -### --target=arm64-apple-darwin -arch x86_64 -arch arm64 2>&1 | FileCheck -check-prefix=TEST5 %s
14+
// TEST5: lipo
15+
// TEST5-NOT: llvm-lipo

0 commit comments

Comments
 (0)