[PATCH] D131820: [PS4][driver] make -fjmc work with LTO driver linking stage
This revision was landed with ongoing or failed builds. This revision was automatically updated to reflect the committed changes. Closed by commit rG288576f474f2: [PS4][driver] make -fjmc work with LTO driver linking stage (authored by ychen). Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D131820/new/ https://reviews.llvm.org/D131820 Files: clang/lib/Driver/ToolChains/PS4CPU.cpp clang/test/Driver/ps4-ps5-linker-jmc.c Index: clang/test/Driver/ps4-ps5-linker-jmc.c === --- /dev/null +++ clang/test/Driver/ps4-ps5-linker-jmc.c @@ -0,0 +1,20 @@ +// Test the driver's control over the JustMyCode behavior with linker flags. + +// RUN: %clang --target=x86_64-scei-ps4 -fjmc %s -### 2>&1 | FileCheck --check-prefixes=CHECK-PS4,CHECK-PS4-LIB %s +// RUN: %clang --target=x86_64-scei-ps4 -flto=thin -fjmc %s -### 2>&1 | FileCheck --check-prefixes=CHECK-PS4-THIN-LTO,CHECK-PS4-LIB %s +// RUN: %clang --target=x86_64-scei-ps4 -flto=full -fjmc %s -### 2>&1 | FileCheck --check-prefixes=CHECK-PS4-FULL-LTO,CHECK-PS4-LIB %s +// RUN: %clang --target=x86_64-scei-ps5 -fjmc %s -### 2>&1 | FileCheck --check-prefixes=CHECK-PS5,CHECK-PS5-LIB %s +// RUN: %clang --target=x86_64-scei-ps5 -flto -fjmc %s -### 2>&1 | FileCheck --check-prefixes=CHECK-PS5-LTO,CHECK-PS5-LIB %s + +// CHECK-PS4-NOT: "-enable-jmc-instrument" + +// CHECK-PS4-THIN-LTO: "-lto-thin-debug-options=-enable-jmc-instrument" +// CHECK-PS4-FULL-LTO: "-lto-debug-options=-enable-jmc-instrument" + +// CHECK-PS5-NOT: "-enable-jmc-instrument" + +// CHECK-PS5-LTO: "-mllvm" "-enable-jmc-instrument" + +// Check the default library name. +// CHECK-PS4-LIB: "--whole-archive" "-lSceDbgJmc" "--no-whole-archive" +// CHECK-PS5-LIB: "--whole-archive" "-lSceJmc_nosubmission" "--no-whole-archive" Index: clang/lib/Driver/ToolChains/PS4CPU.cpp === --- clang/lib/Driver/ToolChains/PS4CPU.cpp +++ clang/lib/Driver/ToolChains/PS4CPU.cpp @@ -152,6 +152,26 @@ assert(Output.isNothing() && "Invalid output."); } + const bool UseLTO = D.isUsingLTO(); + const bool UseJMC = + Args.hasFlag(options::OPT_fjmc, options::OPT_fno_jmc, false); + const bool IsPS4 = TC.getTriple().isPS4(); + const bool IsPS5 = TC.getTriple().isPS5(); + assert(IsPS4 || IsPS5); + + // This tells LTO to perform JustMyCode instrumentation. + if (UseLTO && UseJMC) { +if (IsPS4 && D.getLTOMode() == LTOK_Thin) { + CmdArgs.push_back("-lto-thin-debug-options=-enable-jmc-instrument"); +} else if (IsPS4 && D.getLTOMode() == LTOK_Full) { + CmdArgs.push_back("-lto-debug-options=-enable-jmc-instrument"); +} else if (IsPS5) { + CmdArgs.push_back("-mllvm"); + CmdArgs.push_back("-enable-jmc-instrument"); +} else + llvm_unreachable("new LTO mode?"); + } + if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nodefaultlibs)) TC.addSanitizerArgs(Args, CmdArgs, "-l", ""); @@ -171,6 +191,15 @@ CmdArgs.push_back("-lpthread"); } + if (UseJMC) { +CmdArgs.push_back("--whole-archive"); +if (IsPS4) + CmdArgs.push_back("-lSceDbgJmc"); +else + CmdArgs.push_back("-lSceJmc_nosubmission"); +CmdArgs.push_back("--no-whole-archive"); + } + if (Args.hasArg(options::OPT_fuse_ld_EQ)) { D.Diag(diag::err_drv_unsupported_opt_for_target) << "-fuse-ld" << TC.getTriple().str(); Index: clang/test/Driver/ps4-ps5-linker-jmc.c === --- /dev/null +++ clang/test/Driver/ps4-ps5-linker-jmc.c @@ -0,0 +1,20 @@ +// Test the driver's control over the JustMyCode behavior with linker flags. + +// RUN: %clang --target=x86_64-scei-ps4 -fjmc %s -### 2>&1 | FileCheck --check-prefixes=CHECK-PS4,CHECK-PS4-LIB %s +// RUN: %clang --target=x86_64-scei-ps4 -flto=thin -fjmc %s -### 2>&1 | FileCheck --check-prefixes=CHECK-PS4-THIN-LTO,CHECK-PS4-LIB %s +// RUN: %clang --target=x86_64-scei-ps4 -flto=full -fjmc %s -### 2>&1 | FileCheck --check-prefixes=CHECK-PS4-FULL-LTO,CHECK-PS4-LIB %s +// RUN: %clang --target=x86_64-scei-ps5 -fjmc %s -### 2>&1 | FileCheck --check-prefixes=CHECK-PS5,CHECK-PS5-LIB %s +// RUN: %clang --target=x86_64-scei-ps5 -flto -fjmc %s -### 2>&1 | FileCheck --check-prefixes=CHECK-PS5-LTO,CHECK-PS5-LIB %s + +// CHECK-PS4-NOT: "-enable-jmc-instrument" + +// CHECK-PS4-THIN-LTO: "-lto-thin-debug-options=-enable-jmc-instrument" +// CHECK-PS4-FULL-LTO: "-lto-debug-options=-enable-jmc-instrument" + +// CHECK-PS5-NOT: "-enable-jmc-instrument" + +// CHECK-PS5-LTO: "-mllvm" "-enable-jmc-instrument" + +// Check the default library name. +// CHECK-PS4-LIB: "--whole-archive" "-lSceDbgJmc" "--no-whole-archive" +// CHECK-PS5-LIB: "--whole-archive" "-lSceJmc_nosubmission" "--no-whole-archive" Index: clang/lib/Driver/ToolChains/PS4CPU.cpp === ---
[PATCH] D131820: [PS4][driver] make -fjmc work with LTO driver linking stage
ychen updated this revision to Diff 456427. ychen added a comment. - update Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D131820/new/ https://reviews.llvm.org/D131820 Files: clang/lib/Driver/ToolChains/PS4CPU.cpp clang/test/Driver/ps4-ps5-linker-jmc.c Index: clang/test/Driver/ps4-ps5-linker-jmc.c === --- /dev/null +++ clang/test/Driver/ps4-ps5-linker-jmc.c @@ -0,0 +1,20 @@ +// Test the driver's control over the JustMyCode behavior with linker flags. + +// RUN: %clang --target=x86_64-scei-ps4 -fjmc %s -### 2>&1 | FileCheck --check-prefixes=CHECK-PS4,CHECK-PS4-LIB %s +// RUN: %clang --target=x86_64-scei-ps4 -flto=thin -fjmc %s -### 2>&1 | FileCheck --check-prefixes=CHECK-PS4-THIN-LTO,CHECK-PS4-LIB %s +// RUN: %clang --target=x86_64-scei-ps4 -flto=full -fjmc %s -### 2>&1 | FileCheck --check-prefixes=CHECK-PS4-FULL-LTO,CHECK-PS4-LIB %s +// RUN: %clang --target=x86_64-scei-ps5 -fjmc %s -### 2>&1 | FileCheck --check-prefixes=CHECK-PS5,CHECK-PS5-LIB %s +// RUN: %clang --target=x86_64-scei-ps5 -flto -fjmc %s -### 2>&1 | FileCheck --check-prefixes=CHECK-PS5-LTO,CHECK-PS5-LIB %s + +// CHECK-PS4-NOT: "-enable-jmc-instrument" + +// CHECK-PS4-THIN-LTO: "-lto-thin-debug-options=-enable-jmc-instrument" +// CHECK-PS4-FULL-LTO: "-lto-debug-options=-enable-jmc-instrument" + +// CHECK-PS5-NOT: "-enable-jmc-instrument" + +// CHECK-PS5-LTO: "-mllvm" "-enable-jmc-instrument" + +// Check the default library name. +// CHECK-PS4-LIB: "--whole-archive" "-lSceDbgJmc" "--no-whole-archive" +// CHECK-PS5-LIB: "--whole-archive" "-lSceJmc_nosubmission" "--no-whole-archive" Index: clang/lib/Driver/ToolChains/PS4CPU.cpp === --- clang/lib/Driver/ToolChains/PS4CPU.cpp +++ clang/lib/Driver/ToolChains/PS4CPU.cpp @@ -152,6 +152,26 @@ assert(Output.isNothing() && "Invalid output."); } + const bool UseLTO = D.isUsingLTO(); + const bool UseJMC = + Args.hasFlag(options::OPT_fjmc, options::OPT_fno_jmc, false); + const bool IsPS4 = TC.getTriple().isPS4(); + const bool IsPS5 = TC.getTriple().isPS5(); + assert(IsPS4 || IsPS5); + + // This tells LTO to perform JustMyCode instrumentation. + if (UseLTO && UseJMC) { +if (IsPS4 && D.getLTOMode() == LTOK_Thin) { + CmdArgs.push_back("-lto-thin-debug-options=-enable-jmc-instrument"); +} else if (IsPS4 && D.getLTOMode() == LTOK_Full) { + CmdArgs.push_back("-lto-debug-options=-enable-jmc-instrument"); +} else if (IsPS5) { + CmdArgs.push_back("-mllvm"); + CmdArgs.push_back("-enable-jmc-instrument"); +} else + llvm_unreachable("new LTO mode?"); + } + if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nodefaultlibs)) TC.addSanitizerArgs(Args, CmdArgs, "-l", ""); @@ -171,6 +191,15 @@ CmdArgs.push_back("-lpthread"); } + if (UseJMC) { +CmdArgs.push_back("--whole-archive"); +if (IsPS4) + CmdArgs.push_back("-lSceDbgJmc"); +else + CmdArgs.push_back("-lSceJmc_nosubmission"); +CmdArgs.push_back("--no-whole-archive"); + } + if (Args.hasArg(options::OPT_fuse_ld_EQ)) { D.Diag(diag::err_drv_unsupported_opt_for_target) << "-fuse-ld" << TC.getTriple().str(); Index: clang/test/Driver/ps4-ps5-linker-jmc.c === --- /dev/null +++ clang/test/Driver/ps4-ps5-linker-jmc.c @@ -0,0 +1,20 @@ +// Test the driver's control over the JustMyCode behavior with linker flags. + +// RUN: %clang --target=x86_64-scei-ps4 -fjmc %s -### 2>&1 | FileCheck --check-prefixes=CHECK-PS4,CHECK-PS4-LIB %s +// RUN: %clang --target=x86_64-scei-ps4 -flto=thin -fjmc %s -### 2>&1 | FileCheck --check-prefixes=CHECK-PS4-THIN-LTO,CHECK-PS4-LIB %s +// RUN: %clang --target=x86_64-scei-ps4 -flto=full -fjmc %s -### 2>&1 | FileCheck --check-prefixes=CHECK-PS4-FULL-LTO,CHECK-PS4-LIB %s +// RUN: %clang --target=x86_64-scei-ps5 -fjmc %s -### 2>&1 | FileCheck --check-prefixes=CHECK-PS5,CHECK-PS5-LIB %s +// RUN: %clang --target=x86_64-scei-ps5 -flto -fjmc %s -### 2>&1 | FileCheck --check-prefixes=CHECK-PS5-LTO,CHECK-PS5-LIB %s + +// CHECK-PS4-NOT: "-enable-jmc-instrument" + +// CHECK-PS4-THIN-LTO: "-lto-thin-debug-options=-enable-jmc-instrument" +// CHECK-PS4-FULL-LTO: "-lto-debug-options=-enable-jmc-instrument" + +// CHECK-PS5-NOT: "-enable-jmc-instrument" + +// CHECK-PS5-LTO: "-mllvm" "-enable-jmc-instrument" + +// Check the default library name. +// CHECK-PS4-LIB: "--whole-archive" "-lSceDbgJmc" "--no-whole-archive" +// CHECK-PS5-LIB: "--whole-archive" "-lSceJmc_nosubmission" "--no-whole-archive" Index: clang/lib/Driver/ToolChains/PS4CPU.cpp === --- clang/lib/Driver/ToolChains/PS4CPU.cpp +++ clang/lib/Driver/ToolChains/PS4CPU.cpp @@ -152,6 +152,26 @@ assert(Output.isNothing() && "Invalid output."); } + const bool UseLTO
[PATCH] D131820: [PS4][driver] make -fjmc work with LTO driver linking stage
ychen updated this revision to Diff 456426. ychen added a comment. - use `--target` Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D131820/new/ https://reviews.llvm.org/D131820 Files: clang/lib/Driver/ToolChains/PS4CPU.cpp clang/test/Driver/ps4-ps5-linker-jmc.c Index: clang/test/Driver/ps4-ps5-linker-jmc.c === --- /dev/null +++ clang/test/Driver/ps4-ps5-linker-jmc.c @@ -0,0 +1,20 @@ +// Test the driver's control over the JustMyCode behavior with linker flags. + +// RUN: %clang --target x86_64-scei-ps4 -fjmc %s -### 2>&1 | FileCheck --check-prefixes=CHECK-PS4,CHECK-PS4-LIB %s +// RUN: %clang --target x86_64-scei-ps4 -flto=thin -fjmc %s -### 2>&1 | FileCheck --check-prefixes=CHECK-PS4-THIN-LTO,CHECK-PS4-LIB %s +// RUN: %clang --target x86_64-scei-ps4 -flto=full -fjmc %s -### 2>&1 | FileCheck --check-prefixes=CHECK-PS4-FULL-LTO,CHECK-PS4-LIB %s +// RUN: %clang --target x86_64-scei-ps5 -fjmc %s -### 2>&1 | FileCheck --check-prefixes=CHECK-PS5,CHECK-PS5-LIB %s +// RUN: %clang --target x86_64-scei-ps5 -flto -fjmc %s -### 2>&1 | FileCheck --check-prefixes=CHECK-PS5-LTO,CHECK-PS5-LIB %s + +// CHECK-PS4-NOT: "-enable-jmc-instrument" + +// CHECK-PS4-THIN-LTO: "-lto-thin-debug-options=-enable-jmc-instrument" +// CHECK-PS4-FULL-LTO: "-lto-debug-options=-enable-jmc-instrument" + +// CHECK-PS5-NOT: "-enable-jmc-instrument" + +// CHECK-PS5-LTO: "-mllvm" "-enable-jmc-instrument" + +// Check the default library name. +// CHECK-PS4-LIB: "--whole-archive" "-lSceDbgJmc" "--no-whole-archive" +// CHECK-PS5-LIB: "--whole-archive" "-lSceJmc_nosubmission" "--no-whole-archive" Index: clang/lib/Driver/ToolChains/PS4CPU.cpp === --- clang/lib/Driver/ToolChains/PS4CPU.cpp +++ clang/lib/Driver/ToolChains/PS4CPU.cpp @@ -152,6 +152,26 @@ assert(Output.isNothing() && "Invalid output."); } + const bool UseLTO = D.isUsingLTO(); + const bool UseJMC = + Args.hasFlag(options::OPT_fjmc, options::OPT_fno_jmc, false); + const bool IsPS4 = TC.getTriple().isPS4(); + const bool IsPS5 = TC.getTriple().isPS5(); + assert(IsPS4 || IsPS5); + + // This tells LTO to perform JustMyCode instrumentation. + if (UseLTO && UseJMC) { +if (IsPS4 && D.getLTOMode() == LTOK_Thin) { + CmdArgs.push_back("-lto-thin-debug-options=-enable-jmc-instrument"); +} else if (IsPS4 && D.getLTOMode() == LTOK_Full) { + CmdArgs.push_back("-lto-debug-options=-enable-jmc-instrument"); +} else if (IsPS5) { + CmdArgs.push_back("-mllvm"); + CmdArgs.push_back("-enable-jmc-instrument"); +} else + llvm_unreachable("new LTO mode?"); + } + if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nodefaultlibs)) TC.addSanitizerArgs(Args, CmdArgs, "-l", ""); @@ -171,6 +191,15 @@ CmdArgs.push_back("-lpthread"); } + if (UseJMC) { +CmdArgs.push_back("--whole-archive"); +if (IsPS4) + CmdArgs.push_back("-lSceDbgJmc"); +else + CmdArgs.push_back("-lSceJmc_nosubmission"); +CmdArgs.push_back("--no-whole-archive"); + } + if (Args.hasArg(options::OPT_fuse_ld_EQ)) { D.Diag(diag::err_drv_unsupported_opt_for_target) << "-fuse-ld" << TC.getTriple().str(); Index: clang/test/Driver/ps4-ps5-linker-jmc.c === --- /dev/null +++ clang/test/Driver/ps4-ps5-linker-jmc.c @@ -0,0 +1,20 @@ +// Test the driver's control over the JustMyCode behavior with linker flags. + +// RUN: %clang --target x86_64-scei-ps4 -fjmc %s -### 2>&1 | FileCheck --check-prefixes=CHECK-PS4,CHECK-PS4-LIB %s +// RUN: %clang --target x86_64-scei-ps4 -flto=thin -fjmc %s -### 2>&1 | FileCheck --check-prefixes=CHECK-PS4-THIN-LTO,CHECK-PS4-LIB %s +// RUN: %clang --target x86_64-scei-ps4 -flto=full -fjmc %s -### 2>&1 | FileCheck --check-prefixes=CHECK-PS4-FULL-LTO,CHECK-PS4-LIB %s +// RUN: %clang --target x86_64-scei-ps5 -fjmc %s -### 2>&1 | FileCheck --check-prefixes=CHECK-PS5,CHECK-PS5-LIB %s +// RUN: %clang --target x86_64-scei-ps5 -flto -fjmc %s -### 2>&1 | FileCheck --check-prefixes=CHECK-PS5-LTO,CHECK-PS5-LIB %s + +// CHECK-PS4-NOT: "-enable-jmc-instrument" + +// CHECK-PS4-THIN-LTO: "-lto-thin-debug-options=-enable-jmc-instrument" +// CHECK-PS4-FULL-LTO: "-lto-debug-options=-enable-jmc-instrument" + +// CHECK-PS5-NOT: "-enable-jmc-instrument" + +// CHECK-PS5-LTO: "-mllvm" "-enable-jmc-instrument" + +// Check the default library name. +// CHECK-PS4-LIB: "--whole-archive" "-lSceDbgJmc" "--no-whole-archive" +// CHECK-PS5-LIB: "--whole-archive" "-lSceJmc_nosubmission" "--no-whole-archive" Index: clang/lib/Driver/ToolChains/PS4CPU.cpp === --- clang/lib/Driver/ToolChains/PS4CPU.cpp +++ clang/lib/Driver/ToolChains/PS4CPU.cpp @@ -152,6 +152,26 @@ assert(Output.isNothing() && "Invalid output."); } + const bool
[PATCH] D131820: [PS4][driver] make -fjmc work with LTO driver linking stage
MaskRay added inline comments. Comment at: clang/test/Driver/ps4-ps5-linker-jmc.c:3 + +// RUN: %clang -target x86_64-scei-ps4 -fjmc %s -### 2>&1 | FileCheck --check-prefixes=CHECK-PS4,CHECK-PS4-LIB %s +// RUN: %clang -target x86_64-scei-ps4 -flto=thin -fjmc %s -### 2>&1 | FileCheck --check-prefixes=CHECK-PS4-THIN-LTO,CHECK-PS4-LIB %s `-target ` is legacy. Use `--target=` Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D131820/new/ https://reviews.llvm.org/D131820 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D131820: [PS4][driver] make -fjmc work with LTO driver linking stage
ychen updated this revision to Diff 456415. ychen added a comment. - update Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D131820/new/ https://reviews.llvm.org/D131820 Files: clang/lib/Driver/ToolChains/PS4CPU.cpp clang/test/Driver/ps4-ps5-linker-jmc.c Index: clang/test/Driver/ps4-ps5-linker-jmc.c === --- /dev/null +++ clang/test/Driver/ps4-ps5-linker-jmc.c @@ -0,0 +1,20 @@ +// Test the driver's control over the JustMyCode behavior with linker flags. + +// RUN: %clang -target x86_64-scei-ps4 -fjmc %s -### 2>&1 | FileCheck --check-prefixes=CHECK-PS4,CHECK-PS4-LIB %s +// RUN: %clang -target x86_64-scei-ps4 -flto=thin -fjmc %s -### 2>&1 | FileCheck --check-prefixes=CHECK-PS4-THIN-LTO,CHECK-PS4-LIB %s +// RUN: %clang -target x86_64-scei-ps4 -flto=full -fjmc %s -### 2>&1 | FileCheck --check-prefixes=CHECK-PS4-FULL-LTO,CHECK-PS4-LIB %s +// RUN: %clang -target x86_64-scei-ps5 -fjmc %s -### 2>&1 | FileCheck --check-prefixes=CHECK-PS5,CHECK-PS5-LIB %s +// RUN: %clang -target x86_64-scei-ps5 -flto -fjmc %s -### 2>&1 | FileCheck --check-prefixes=CHECK-PS5-LTO,CHECK-PS5-LIB %s + +// CHECK-PS4-NOT: "-enable-jmc-instrument" + +// CHECK-PS4-THIN-LTO: "-lto-thin-debug-options=-enable-jmc-instrument" +// CHECK-PS4-FULL-LTO: "-lto-debug-options=-enable-jmc-instrument" + +// CHECK-PS5-NOT: "-enable-jmc-instrument" + +// CHECK-PS5-LTO: "-mllvm" "-enable-jmc-instrument" + +// Check the default library name. +// CHECK-PS4-LIB: "--whole-archive" "-lSceDbgJmc" "--no-whole-archive" +// CHECK-PS5-LIB: "--whole-archive" "-lSceJmc_nosubmission" "--no-whole-archive" Index: clang/lib/Driver/ToolChains/PS4CPU.cpp === --- clang/lib/Driver/ToolChains/PS4CPU.cpp +++ clang/lib/Driver/ToolChains/PS4CPU.cpp @@ -152,6 +152,26 @@ assert(Output.isNothing() && "Invalid output."); } + const bool UseLTO = D.isUsingLTO(); + const bool UseJMC = + Args.hasFlag(options::OPT_fjmc, options::OPT_fno_jmc, false); + const bool IsPS4 = TC.getTriple().isPS4(); + const bool IsPS5 = TC.getTriple().isPS5(); + assert(IsPS4 || IsPS5); + + // This tells LTO to perform JustMyCode instrumentation. + if (UseLTO && UseJMC) { +if (IsPS4 && D.getLTOMode() == LTOK_Thin) { + CmdArgs.push_back("-lto-thin-debug-options=-enable-jmc-instrument"); +} else if (IsPS4 && D.getLTOMode() == LTOK_Full) { + CmdArgs.push_back("-lto-debug-options=-enable-jmc-instrument"); +} else if (IsPS5) { + CmdArgs.push_back("-mllvm"); + CmdArgs.push_back("-enable-jmc-instrument"); +} else + llvm_unreachable("new LTO mode?"); + } + if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nodefaultlibs)) TC.addSanitizerArgs(Args, CmdArgs, "-l", ""); @@ -171,6 +191,15 @@ CmdArgs.push_back("-lpthread"); } + if (UseJMC) { +CmdArgs.push_back("--whole-archive"); +if (IsPS4) + CmdArgs.push_back("-lSceDbgJmc"); +else + CmdArgs.push_back("-lSceJmc_nosubmission"); +CmdArgs.push_back("--no-whole-archive"); + } + if (Args.hasArg(options::OPT_fuse_ld_EQ)) { D.Diag(diag::err_drv_unsupported_opt_for_target) << "-fuse-ld" << TC.getTriple().str(); Index: clang/test/Driver/ps4-ps5-linker-jmc.c === --- /dev/null +++ clang/test/Driver/ps4-ps5-linker-jmc.c @@ -0,0 +1,20 @@ +// Test the driver's control over the JustMyCode behavior with linker flags. + +// RUN: %clang -target x86_64-scei-ps4 -fjmc %s -### 2>&1 | FileCheck --check-prefixes=CHECK-PS4,CHECK-PS4-LIB %s +// RUN: %clang -target x86_64-scei-ps4 -flto=thin -fjmc %s -### 2>&1 | FileCheck --check-prefixes=CHECK-PS4-THIN-LTO,CHECK-PS4-LIB %s +// RUN: %clang -target x86_64-scei-ps4 -flto=full -fjmc %s -### 2>&1 | FileCheck --check-prefixes=CHECK-PS4-FULL-LTO,CHECK-PS4-LIB %s +// RUN: %clang -target x86_64-scei-ps5 -fjmc %s -### 2>&1 | FileCheck --check-prefixes=CHECK-PS5,CHECK-PS5-LIB %s +// RUN: %clang -target x86_64-scei-ps5 -flto -fjmc %s -### 2>&1 | FileCheck --check-prefixes=CHECK-PS5-LTO,CHECK-PS5-LIB %s + +// CHECK-PS4-NOT: "-enable-jmc-instrument" + +// CHECK-PS4-THIN-LTO: "-lto-thin-debug-options=-enable-jmc-instrument" +// CHECK-PS4-FULL-LTO: "-lto-debug-options=-enable-jmc-instrument" + +// CHECK-PS5-NOT: "-enable-jmc-instrument" + +// CHECK-PS5-LTO: "-mllvm" "-enable-jmc-instrument" + +// Check the default library name. +// CHECK-PS4-LIB: "--whole-archive" "-lSceDbgJmc" "--no-whole-archive" +// CHECK-PS5-LIB: "--whole-archive" "-lSceJmc_nosubmission" "--no-whole-archive" Index: clang/lib/Driver/ToolChains/PS4CPU.cpp === --- clang/lib/Driver/ToolChains/PS4CPU.cpp +++ clang/lib/Driver/ToolChains/PS4CPU.cpp @@ -152,6 +152,26 @@ assert(Output.isNothing() && "Invalid output."); } + const bool UseLTO =
[PATCH] D131820: [PS4][driver] make -fjmc work with LTO driver linking stage
probinson accepted this revision. probinson added a comment. This revision is now accepted and ready to land. LGTM with one comment on the test. Comment at: clang/test/Driver/ps4-ps5-linker-jmc.c:1 +// REQUIRES: x86-registered-target + This REQUIRES is not necessary. The driver is aware of all possible triples. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D131820/new/ https://reviews.llvm.org/D131820 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D131820: [PS4][driver] make -fjmc work with LTO driver linking stage
ychen added a comment. ping Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D131820/new/ https://reviews.llvm.org/D131820 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D131820: [PS4][driver] make -fjmc work with LTO driver linking stage
ychen created this revision. ychen added a reviewer: probinson. Herald added a subscriber: inglorion. Herald added a project: All. ychen requested review of this revision. Herald added subscribers: cfe-commits, MaskRay. Herald added a project: clang. Repository: rG LLVM Github Monorepo https://reviews.llvm.org/D131820 Files: clang/lib/Driver/ToolChains/PS4CPU.cpp clang/test/Driver/ps4-ps5-linker-jmc.c Index: clang/test/Driver/ps4-ps5-linker-jmc.c === --- /dev/null +++ clang/test/Driver/ps4-ps5-linker-jmc.c @@ -0,0 +1,22 @@ +// REQUIRES: x86-registered-target + +// Test the driver's control over the JustMyCode behavior with linker flags. + +// RUN: %clang -target x86_64-scei-ps4 -fjmc %s -### 2>&1 | FileCheck --check-prefixes=CHECK-PS4,CHECK-PS4-LIB %s +// RUN: %clang -target x86_64-scei-ps4 -flto=thin -fjmc %s -### 2>&1 | FileCheck --check-prefixes=CHECK-PS4-THIN-LTO,CHECK-PS4-LIB %s +// RUN: %clang -target x86_64-scei-ps4 -flto=full -fjmc %s -### 2>&1 | FileCheck --check-prefixes=CHECK-PS4-FULL-LTO,CHECK-PS4-LIB %s +// RUN: %clang -target x86_64-scei-ps5 -fjmc %s -### 2>&1 | FileCheck --check-prefixes=CHECK-PS5,CHECK-PS5-LIB %s +// RUN: %clang -target x86_64-scei-ps5 -flto -fjmc %s -### 2>&1 | FileCheck --check-prefixes=CHECK-PS5-LTO,CHECK-PS5-LIB %s + +// CHECK-PS4-NOT: "-enable-jmc-instrument" + +// CHECK-PS4-THIN-LTO: "-lto-thin-debug-options=-enable-jmc-instrument" +// CHECK-PS4-FULL-LTO: "-lto-debug-options=-enable-jmc-instrument" + +// CHECK-PS5-NOT: "-enable-jmc-instrument" + +// CHECK-PS5-LTO: "-mllvm" "-enable-jmc-instrument" + +// Check the default library name. +// CHECK-PS4-LIB: "--whole-archive" "-lSceDbgJmc" "--no-whole-archive" +// CHECK-PS5-LIB: "--whole-archive" "-lSceJmc_nosubmission" "--no-whole-archive" Index: clang/lib/Driver/ToolChains/PS4CPU.cpp === --- clang/lib/Driver/ToolChains/PS4CPU.cpp +++ clang/lib/Driver/ToolChains/PS4CPU.cpp @@ -152,6 +152,26 @@ assert(Output.isNothing() && "Invalid output."); } + const bool UseLTO = D.isUsingLTO(); + const bool UseJMC = + Args.hasFlag(options::OPT_fjmc, options::OPT_fno_jmc, false); + const bool IsPS4 = TC.getTriple().isPS4(); + const bool IsPS5 = TC.getTriple().isPS5(); + assert(IsPS4 || IsPS5); + + // This tells LTO to perform JustMyCode instrumentation. + if (UseLTO && UseJMC) { +if (IsPS4 && D.getLTOMode() == LTOK_Thin) { + CmdArgs.push_back("-lto-thin-debug-options=-enable-jmc-instrument"); +} else if (IsPS4 && D.getLTOMode() == LTOK_Full) { + CmdArgs.push_back("-lto-debug-options=-enable-jmc-instrument"); +} else if (IsPS5) { + CmdArgs.push_back("-mllvm"); + CmdArgs.push_back("-enable-jmc-instrument"); +} else + llvm_unreachable("new LTO mode?"); + } + if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nodefaultlibs)) TC.addSanitizerArgs(Args, CmdArgs, "-l", ""); @@ -171,6 +191,15 @@ CmdArgs.push_back("-lpthread"); } + if (UseJMC) { +CmdArgs.push_back("--whole-archive"); +if (IsPS4) + CmdArgs.push_back("-lSceDbgJmc"); +else + CmdArgs.push_back("-lSceJmc_nosubmission"); +CmdArgs.push_back("--no-whole-archive"); + } + if (Args.hasArg(options::OPT_fuse_ld_EQ)) { D.Diag(diag::err_drv_unsupported_opt_for_target) << "-fuse-ld" << TC.getTriple().str(); Index: clang/test/Driver/ps4-ps5-linker-jmc.c === --- /dev/null +++ clang/test/Driver/ps4-ps5-linker-jmc.c @@ -0,0 +1,22 @@ +// REQUIRES: x86-registered-target + +// Test the driver's control over the JustMyCode behavior with linker flags. + +// RUN: %clang -target x86_64-scei-ps4 -fjmc %s -### 2>&1 | FileCheck --check-prefixes=CHECK-PS4,CHECK-PS4-LIB %s +// RUN: %clang -target x86_64-scei-ps4 -flto=thin -fjmc %s -### 2>&1 | FileCheck --check-prefixes=CHECK-PS4-THIN-LTO,CHECK-PS4-LIB %s +// RUN: %clang -target x86_64-scei-ps4 -flto=full -fjmc %s -### 2>&1 | FileCheck --check-prefixes=CHECK-PS4-FULL-LTO,CHECK-PS4-LIB %s +// RUN: %clang -target x86_64-scei-ps5 -fjmc %s -### 2>&1 | FileCheck --check-prefixes=CHECK-PS5,CHECK-PS5-LIB %s +// RUN: %clang -target x86_64-scei-ps5 -flto -fjmc %s -### 2>&1 | FileCheck --check-prefixes=CHECK-PS5-LTO,CHECK-PS5-LIB %s + +// CHECK-PS4-NOT: "-enable-jmc-instrument" + +// CHECK-PS4-THIN-LTO: "-lto-thin-debug-options=-enable-jmc-instrument" +// CHECK-PS4-FULL-LTO: "-lto-debug-options=-enable-jmc-instrument" + +// CHECK-PS5-NOT: "-enable-jmc-instrument" + +// CHECK-PS5-LTO: "-mllvm" "-enable-jmc-instrument" + +// Check the default library name. +// CHECK-PS4-LIB: "--whole-archive" "-lSceDbgJmc" "--no-whole-archive" +// CHECK-PS5-LIB: "--whole-archive" "-lSceJmc_nosubmission" "--no-whole-archive" Index: clang/lib/Driver/ToolChains/PS4CPU.cpp === ---