diff --git a/src/main/java/com/google/devtools/build/lib/rules/cpp/LinkCommandLine.java b/src/main/java/com/google/devtools/build/lib/rules/cpp/LinkCommandLine.java index b26e71c76bf501..8bd65bb8897542 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/cpp/LinkCommandLine.java +++ b/src/main/java/com/google/devtools/build/lib/rules/cpp/LinkCommandLine.java @@ -276,13 +276,13 @@ CommandLine paramCmdLine() { paramFile, linkTargetType, forcedToolPath, featureConfiguration, actionName, variables); } - public static void extractArgumentsForStaticLinkParamFile( + private static void extractArgumentsForStaticLinkParamFile( List args, List commandlineArgs, List paramFileArgs) { commandlineArgs.add(args.get(0)); // ar command, must not be moved! int argsSize = args.size(); for (int i = 1; i < argsSize; i++) { String arg = args.get(i); - if (arg.startsWith("@")) { + if (isLikelyParamFile(arg)) { commandlineArgs.add(arg); // params file, keep it in the command line } else { paramFileArgs.add(arg); // the rest goes to the params file @@ -290,7 +290,7 @@ public static void extractArgumentsForStaticLinkParamFile( } } - public static void extractArgumentsForDynamicLinkParamFile( + private static void extractArgumentsForDynamicLinkParamFile( List args, List commandlineArgs, List paramFileArgs) { // Note, that it is not important that all linker arguments are extracted so that // they can be moved into a parameter file, but the vast majority should. @@ -298,7 +298,7 @@ public static void extractArgumentsForDynamicLinkParamFile( int argsSize = args.size(); for (int i = 1; i < argsSize; i++) { String arg = args.get(i); - if (arg.startsWith("@")) { + if (isLikelyParamFile(arg)) { commandlineArgs.add(arg); // params file, keep it in the command line } else { paramFileArgs.add(arg); // the rest goes to the params file @@ -306,6 +306,13 @@ public static void extractArgumentsForDynamicLinkParamFile( } } + private static boolean isLikelyParamFile(String arg) { + return arg.startsWith("@") + && !arg.startsWith("@rpath") + && !arg.startsWith("@loader_path") + && !arg.startsWith("@executable_path"); + } + /** * Returns a raw link command for the given link invocation, including both command and arguments * (argv). The version that uses the expander is preferred, but that one can't be used during