[PATCH] D38226: [XRay][Driver] Do not link in XRay runtime in shared libs
dberris closed this revision. dberris added a comment. Already landed; manually closing. https://reviews.llvm.org/D38226 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D38226: [XRay][Driver] Do not link in XRay runtime in shared libs
dberris updated this revision to Diff 116637. dberris added a comment. Herald added a subscriber: srhines. - fixup: use supported target list in test from clang implementation https://reviews.llvm.org/D38226 Files: lib/Driver/ToolChains/Gnu.cpp test/Driver/XRay/lit.local.cfg test/Driver/XRay/xray-shared-noxray.cpp Index: test/Driver/XRay/xray-shared-noxray.cpp === --- /dev/null +++ test/Driver/XRay/xray-shared-noxray.cpp @@ -0,0 +1,16 @@ +// RUN: %clangxx -shared -fPIC -o /dev/null -v -fxray-instrument %s 2>&1 | \ +// RUN: FileCheck %s --check-prefix=SHARED +// RUN: %clangxx -static -o /dev/null -v -fxray-instrument %s 2>&1 -DMAIN | \ +// RUN: FileCheck %s --check-prefix=STATIC +// RUN: %clangxx -static -fPIE -o /dev/null -v -fxray-instrument %s 2>&1 \ +// RUN: -DMAIN | FileCheck %s --check-prefix=STATIC +// +// SHARED-NOT: {{clang_rt\.xray-}} +// STATIC: {{clang_rt\.xray-}} +// +// REQUIRES: linux +int foo() { return 42; } + +#ifdef MAIN +int main() { return foo(); } +#endif Index: test/Driver/XRay/lit.local.cfg === --- test/Driver/XRay/lit.local.cfg +++ test/Driver/XRay/lit.local.cfg @@ -1,2 +1,21 @@ target_triple_components = config.target_triple.split('-') config.available_features.update(target_triple_components) + +# Only run the tests in platforms where XRay instrumentation is supported. +supported_targets = [ +'amd64', 'x86_64', 'x86_64h', 'arm', 'aarch64', 'arm64', 'powerpc64le', +'mips', 'mipsel', 'mips64', 'mips64el' +] + +# Only on platforms we support. +supported_oses = [ +'linux' +] + +triple_set = set(target_triple_components) +if len(triple_set.intersection(supported_targets)) == 0: + config.unsupported = True + +# Do not run for 'android' despite being linux. +if len(triple_set.intersection(supported_oses)) == 0 or 'android' in triple_set: + config.unsupported = True Index: lib/Driver/ToolChains/Gnu.cpp === --- lib/Driver/ToolChains/Gnu.cpp +++ lib/Driver/ToolChains/Gnu.cpp @@ -206,13 +206,18 @@ static bool addXRayRuntime(const ToolChain &TC, const ArgList &Args, ArgStringList &CmdArgs) { + // Do not add the XRay runtime to shared libraries. + if (Args.hasArg(options::OPT_shared)) +return false; + if (Args.hasFlag(options::OPT_fxray_instrument, options::OPT_fnoxray_instrument, false)) { CmdArgs.push_back("-whole-archive"); CmdArgs.push_back(TC.getCompilerRTArgString(Args, "xray", false)); CmdArgs.push_back("-no-whole-archive"); return true; } + return false; } Index: test/Driver/XRay/xray-shared-noxray.cpp === --- /dev/null +++ test/Driver/XRay/xray-shared-noxray.cpp @@ -0,0 +1,16 @@ +// RUN: %clangxx -shared -fPIC -o /dev/null -v -fxray-instrument %s 2>&1 | \ +// RUN: FileCheck %s --check-prefix=SHARED +// RUN: %clangxx -static -o /dev/null -v -fxray-instrument %s 2>&1 -DMAIN | \ +// RUN: FileCheck %s --check-prefix=STATIC +// RUN: %clangxx -static -fPIE -o /dev/null -v -fxray-instrument %s 2>&1 \ +// RUN: -DMAIN | FileCheck %s --check-prefix=STATIC +// +// SHARED-NOT: {{clang_rt\.xray-}} +// STATIC: {{clang_rt\.xray-}} +// +// REQUIRES: linux +int foo() { return 42; } + +#ifdef MAIN +int main() { return foo(); } +#endif Index: test/Driver/XRay/lit.local.cfg === --- test/Driver/XRay/lit.local.cfg +++ test/Driver/XRay/lit.local.cfg @@ -1,2 +1,21 @@ target_triple_components = config.target_triple.split('-') config.available_features.update(target_triple_components) + +# Only run the tests in platforms where XRay instrumentation is supported. +supported_targets = [ +'amd64', 'x86_64', 'x86_64h', 'arm', 'aarch64', 'arm64', 'powerpc64le', +'mips', 'mipsel', 'mips64', 'mips64el' +] + +# Only on platforms we support. +supported_oses = [ +'linux' +] + +triple_set = set(target_triple_components) +if len(triple_set.intersection(supported_targets)) == 0: + config.unsupported = True + +# Do not run for 'android' despite being linux. +if len(triple_set.intersection(supported_oses)) == 0 or 'android' in triple_set: + config.unsupported = True Index: lib/Driver/ToolChains/Gnu.cpp === --- lib/Driver/ToolChains/Gnu.cpp +++ lib/Driver/ToolChains/Gnu.cpp @@ -206,13 +206,18 @@ static bool addXRayRuntime(const ToolChain &TC, const ArgList &Args, ArgStringList &CmdArgs) { + // Do not add the XRay runtime to shared libraries. + if (Args.hasArg(options::OPT_shared)) +return false; + if (Args.hasFlag(options::OPT_fxray_instrument, options::OPT_fnoxray_instrument, false)) { CmdArgs.push_back("-whole-archive"); C
[PATCH] D38226: [XRay][Driver] Do not link in XRay runtime in shared libs
dberris updated this revision to Diff 116631. dberris added a comment. - fixup: limit tests to run on supported platforms and oses https://reviews.llvm.org/D38226 Files: lib/Driver/ToolChains/Gnu.cpp test/Driver/XRay/lit.local.cfg test/Driver/XRay/xray-shared-noxray.cpp Index: test/Driver/XRay/xray-shared-noxray.cpp === --- /dev/null +++ test/Driver/XRay/xray-shared-noxray.cpp @@ -0,0 +1,16 @@ +// RUN: %clangxx -shared -fPIC -o /dev/null -v -fxray-instrument %s 2>&1 | \ +// RUN: FileCheck %s --check-prefix=SHARED +// RUN: %clangxx -static -o /dev/null -v -fxray-instrument %s 2>&1 -DMAIN | \ +// RUN: FileCheck %s --check-prefix=STATIC +// RUN: %clangxx -static -fPIE -o /dev/null -v -fxray-instrument %s 2>&1 \ +// RUN: -DMAIN | FileCheck %s --check-prefix=STATIC +// +// SHARED-NOT: {{clang_rt\.xray-}} +// STATIC: {{clang_rt\.xray-}} +// +// REQUIRES: linux +int foo() { return 42; } + +#ifdef MAIN +int main() { return foo(); } +#endif Index: test/Driver/XRay/lit.local.cfg === --- test/Driver/XRay/lit.local.cfg +++ test/Driver/XRay/lit.local.cfg @@ -1,2 +1,20 @@ target_triple_components = config.target_triple.split('-') config.available_features.update(target_triple_components) + +# Only run the tests in platforms where XRay instrumentation is supported. +supported_targets = [ +'amd64', 'x86_64', 'x86_64h', 'arm7', 'arm8', 'aarch64', 'arm64', +'powerpc64le', 'mips', 'mipsel', 'mips64', 'mips64el' +] + +# Only on platforms we support. +supported_oses = [ +'linux' +] + +triple_set = set(target_triple_components) +if len(triple_set.intersection(supported_targets)) == 0: + config.unsupported = True + +if len(triple_set.intersection(supported_oses)) == 0: + config.unsupported = True Index: lib/Driver/ToolChains/Gnu.cpp === --- lib/Driver/ToolChains/Gnu.cpp +++ lib/Driver/ToolChains/Gnu.cpp @@ -206,13 +206,18 @@ static bool addXRayRuntime(const ToolChain &TC, const ArgList &Args, ArgStringList &CmdArgs) { + // Do not add the XRay runtime to shared libraries. + if (Args.hasArg(options::OPT_shared)) +return false; + if (Args.hasFlag(options::OPT_fxray_instrument, options::OPT_fnoxray_instrument, false)) { CmdArgs.push_back("-whole-archive"); CmdArgs.push_back(TC.getCompilerRTArgString(Args, "xray", false)); CmdArgs.push_back("-no-whole-archive"); return true; } + return false; } Index: test/Driver/XRay/xray-shared-noxray.cpp === --- /dev/null +++ test/Driver/XRay/xray-shared-noxray.cpp @@ -0,0 +1,16 @@ +// RUN: %clangxx -shared -fPIC -o /dev/null -v -fxray-instrument %s 2>&1 | \ +// RUN: FileCheck %s --check-prefix=SHARED +// RUN: %clangxx -static -o /dev/null -v -fxray-instrument %s 2>&1 -DMAIN | \ +// RUN: FileCheck %s --check-prefix=STATIC +// RUN: %clangxx -static -fPIE -o /dev/null -v -fxray-instrument %s 2>&1 \ +// RUN: -DMAIN | FileCheck %s --check-prefix=STATIC +// +// SHARED-NOT: {{clang_rt\.xray-}} +// STATIC: {{clang_rt\.xray-}} +// +// REQUIRES: linux +int foo() { return 42; } + +#ifdef MAIN +int main() { return foo(); } +#endif Index: test/Driver/XRay/lit.local.cfg === --- test/Driver/XRay/lit.local.cfg +++ test/Driver/XRay/lit.local.cfg @@ -1,2 +1,20 @@ target_triple_components = config.target_triple.split('-') config.available_features.update(target_triple_components) + +# Only run the tests in platforms where XRay instrumentation is supported. +supported_targets = [ +'amd64', 'x86_64', 'x86_64h', 'arm7', 'arm8', 'aarch64', 'arm64', +'powerpc64le', 'mips', 'mipsel', 'mips64', 'mips64el' +] + +# Only on platforms we support. +supported_oses = [ +'linux' +] + +triple_set = set(target_triple_components) +if len(triple_set.intersection(supported_targets)) == 0: + config.unsupported = True + +if len(triple_set.intersection(supported_oses)) == 0: + config.unsupported = True Index: lib/Driver/ToolChains/Gnu.cpp === --- lib/Driver/ToolChains/Gnu.cpp +++ lib/Driver/ToolChains/Gnu.cpp @@ -206,13 +206,18 @@ static bool addXRayRuntime(const ToolChain &TC, const ArgList &Args, ArgStringList &CmdArgs) { + // Do not add the XRay runtime to shared libraries. + if (Args.hasArg(options::OPT_shared)) +return false; + if (Args.hasFlag(options::OPT_fxray_instrument, options::OPT_fnoxray_instrument, false)) { CmdArgs.push_back("-whole-archive"); CmdArgs.push_back(TC.getCompilerRTArgString(Args, "xray", false)); CmdArgs.push_back("-no-whole-archive"); return true; } + return false; } __
[PATCH] D38226: [XRay][Driver] Do not link in XRay runtime in shared libs
rnk accepted this revision. rnk added a comment. This revision is now accepted and ready to land. Looks good https://reviews.llvm.org/D38226 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D38226: [XRay][Driver] Do not link in XRay runtime in shared libs
dberris created this revision. This change ensures that we don't link in the XRay runtime when building shared libraries with clang. This doesn't prevent us from building shared libraris tht have XRay instrumentation sleds, but it does prevent us from linking in the static XRay runtime into a shared library. The XRay runtime currently doesn't support dynamic registration of instrumentation sleds in shared objects, which we'll start enabling in the future. That work has to happen in the back-end and in the runtime. https://reviews.llvm.org/D38226 Files: lib/Driver/ToolChains/Gnu.cpp test/Driver/XRay/xray-shared-noxray.cpp Index: test/Driver/XRay/xray-shared-noxray.cpp === --- /dev/null +++ test/Driver/XRay/xray-shared-noxray.cpp @@ -0,0 +1,14 @@ +// RUN: %clangxx -shared -fPIC -o /dev/null -v -fxray-instrument %s 2>&1 | \ +// RUN: FileCheck %s --check-prefix=SHARED +// RUN: %clangxx -static -o /dev/null -v -fxray-instrument %s 2>&1 -DMAIN | \ +// RUN: FileCheck %s --check-prefix=STATIC +// RUN: %clangxx -static -fPIE -o /dev/null -v -fxray-instrument %s 2>&1 \ +// RUN: -DMAIN | FileCheck %s --check-prefix=STATIC +// +// SHARED-NOT: {{clang_rt\.xray-}} +// STATIC: {{clang_rt\.xray-}} +int foo() { return 42; } + +#ifdef MAIN +int main() { return foo(); } +#endif Index: lib/Driver/ToolChains/Gnu.cpp === --- lib/Driver/ToolChains/Gnu.cpp +++ lib/Driver/ToolChains/Gnu.cpp @@ -206,13 +206,18 @@ static bool addXRayRuntime(const ToolChain &TC, const ArgList &Args, ArgStringList &CmdArgs) { + // Do not add the XRay runtime to shared libraries. + if (Args.hasArg(options::OPT_shared)) +return false; + if (Args.hasFlag(options::OPT_fxray_instrument, options::OPT_fnoxray_instrument, false)) { CmdArgs.push_back("-whole-archive"); CmdArgs.push_back(TC.getCompilerRTArgString(Args, "xray", false)); CmdArgs.push_back("-no-whole-archive"); return true; } + return false; } Index: test/Driver/XRay/xray-shared-noxray.cpp === --- /dev/null +++ test/Driver/XRay/xray-shared-noxray.cpp @@ -0,0 +1,14 @@ +// RUN: %clangxx -shared -fPIC -o /dev/null -v -fxray-instrument %s 2>&1 | \ +// RUN: FileCheck %s --check-prefix=SHARED +// RUN: %clangxx -static -o /dev/null -v -fxray-instrument %s 2>&1 -DMAIN | \ +// RUN: FileCheck %s --check-prefix=STATIC +// RUN: %clangxx -static -fPIE -o /dev/null -v -fxray-instrument %s 2>&1 \ +// RUN: -DMAIN | FileCheck %s --check-prefix=STATIC +// +// SHARED-NOT: {{clang_rt\.xray-}} +// STATIC: {{clang_rt\.xray-}} +int foo() { return 42; } + +#ifdef MAIN +int main() { return foo(); } +#endif Index: lib/Driver/ToolChains/Gnu.cpp === --- lib/Driver/ToolChains/Gnu.cpp +++ lib/Driver/ToolChains/Gnu.cpp @@ -206,13 +206,18 @@ static bool addXRayRuntime(const ToolChain &TC, const ArgList &Args, ArgStringList &CmdArgs) { + // Do not add the XRay runtime to shared libraries. + if (Args.hasArg(options::OPT_shared)) +return false; + if (Args.hasFlag(options::OPT_fxray_instrument, options::OPT_fnoxray_instrument, false)) { CmdArgs.push_back("-whole-archive"); CmdArgs.push_back(TC.getCompilerRTArgString(Args, "xray", false)); CmdArgs.push_back("-no-whole-archive"); return true; } + return false; } ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits