-
Notifications
You must be signed in to change notification settings - Fork 10.5k
Add '-emit-archive' option to mark modules as being part of static libraries #25088
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
0b7369c
ff3498c
d0eb649
2af0bae
bdcac7f
2421f37
d82e47a
3463e5d
248b0f7
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -208,6 +208,7 @@ static void addCommonFrontendArgs(const ToolChain &TC, const OutputInfo &OI, | |
inputArgs.AddLastArg(arguments, options::OPT_warnings_as_errors); | ||
inputArgs.AddLastArg(arguments, options::OPT_sanitize_EQ); | ||
inputArgs.AddLastArg(arguments, options::OPT_sanitize_coverage_EQ); | ||
inputArgs.AddLastArg(arguments, options::OPT_static); | ||
inputArgs.AddLastArg(arguments, options::OPT_swift_version); | ||
inputArgs.AddLastArg(arguments, options::OPT_enforce_exclusivity_EQ); | ||
inputArgs.AddLastArg(arguments, options::OPT_stats_output_dir); | ||
|
@@ -1078,6 +1079,73 @@ ToolChain::constructInvocation(const LinkJobAction &job, | |
llvm_unreachable("linking not implemented for this toolchain"); | ||
} | ||
|
||
ToolChain::InvocationInfo | ||
ToolChain::constructInvocation(const ArchiveJobAction &job, | ||
const JobContext &context) const { | ||
assert(context.Output.getPrimaryOutputType() == file_types::TY_Image && | ||
"Invalid linker output type."); | ||
|
||
ArgStringList Arguments; | ||
|
||
// Configure the toolchain. | ||
bool isLLVMAR = false; | ||
const char *AR = nullptr; | ||
if (const Arg *A = context.Args.getLastArg(options::OPT_tools_directory)) { | ||
StringRef toolchainPath(A->getValue()); | ||
|
||
// If there is an llvm-ar in the toolchain folder, use that instead. | ||
if (auto toolchainAR = | ||
llvm::sys::findProgramByName("llvm-ar", {toolchainPath})) { | ||
AR = context.Args.MakeArgString(toolchainAR.get()); | ||
isLLVMAR = true; | ||
} | ||
|
||
} | ||
if (AR == nullptr) { | ||
if (auto pathAR = llvm::sys::findProgramByName("llvm-ar", None)) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not sure we actually want to prefer @cooperp, what's the current recommendation on this? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I believe it's libtool. Otherwise you tend to have to call ranlib after ar, while the man page for libtool says it can handle both for you: "Libtool with -static is intended to replace ar(5) and ranlib." There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @compnerd, is what’s here what we want on both GenericUnix and Windows, or should the behaviour differ? If There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @cooperp - thats the trick wrt There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Xcode doesn't ship with There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sure, but it does ship with There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hm. I'll let @cooperp decide what's right here. We already aren't getting code sharing because the Darwin toolchain deliberately isn't a GenericUnix toolchain, on account of Apple There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @cooperp, what do you think is best here? |
||
AR = context.Args.MakeArgString(pathAR.get()); | ||
isLLVMAR = true; | ||
} | ||
} | ||
if (AR == nullptr) { | ||
if (auto pathAR = llvm::sys::findProgramByName("ar", None)) | ||
AR = context.Args.MakeArgString(pathAR.get()); | ||
} | ||
|
||
assert(AR && | ||
"neither ar nor llvm-ar was not found in the toolchain directory or system path."); | ||
|
||
if (isLLVMAR) { | ||
switch (getTriple().getOS()) { | ||
case llvm::Triple::Darwin: | ||
Arguments.push_back("--format=darwin"); | ||
break; | ||
case llvm::Triple::FreeBSD: | ||
Arguments.push_back("--format=bsd"); | ||
break; | ||
case llvm::Triple::Linux: | ||
Arguments.push_back("--format=gnu"); | ||
break; | ||
default: | ||
break; | ||
} | ||
} | ||
|
||
Arguments.push_back("crs"); | ||
|
||
Arguments.push_back( | ||
context.Args.MakeArgString(context.Output.getPrimaryOutputFilename())); | ||
|
||
addPrimaryInputsOfType(Arguments, context.Inputs, context.Args, | ||
file_types::TY_Object); | ||
addInputsOfType(Arguments, context.InputActions, file_types::TY_Object); | ||
|
||
InvocationInfo II{AR, Arguments}; | ||
II.allowsResponseFiles = true; | ||
|
||
return II; | ||
} | ||
|
||
void ToolChain::addPathEnvironmentVariableIfNeeded( | ||
Job::EnvironmentVector &env, const char *name, const char *separator, | ||
options::ID optionID, const ArgList &args, StringRef extraEntry) const { | ||
|
Uh oh!
There was an error while loading. Please reload this page.