Author: ed Date: Sat Aug 13 15:43:56 2016 New Revision: 278605 URL: http://llvm.org/viewvc/llvm-project?rev=278605&view=rev Log: Merge r278393 and r278395.
LLVM/Clang 3.8 is directly usable as a cross compiler for CloudABI/i686. In 3.9rc1 there are a couple of regressions in the driver that cause it to be less usable: - PIE was enabled unconditionally, even though it's only available for x86-64 and aarch64. - Some inline assembly fails to build, due to a shortage of registers, as frame pointers are not omitted. Both these changes are fairly low risk (read: they don't affect other targets), so go ahead and merge them into 3.9, so we can use an unmodified compiler on all architectures. Modified: cfe/branches/release_39/ (props changed) cfe/branches/release_39/lib/Driver/ToolChains.cpp cfe/branches/release_39/lib/Driver/ToolChains.h cfe/branches/release_39/lib/Driver/Tools.cpp cfe/branches/release_39/test/Driver/cloudabi.c cfe/branches/release_39/test/Driver/cloudabi.cpp cfe/branches/release_39/test/Driver/frame-pointer-elim.c Propchange: cfe/branches/release_39/ ------------------------------------------------------------------------------ --- svn:mergeinfo (original) +++ svn:mergeinfo Sat Aug 13 15:43:56 2016 @@ -1,4 +1,4 @@ /cfe/branches/type-system-rewrite:134693-134817 -/cfe/trunk:275880,275967,276102,276350,276361,276473,276653,276716,276887,276891,276900,276979,276983,277095,277138,277141,277221,277307,277522,277743,277796-277797,277866,277889,277900,278139,278234-278235 +/cfe/trunk:275880,275967,276102,276350,276361,276473,276653,276716,276887,276891,276900,276979,276983,277095,277138,277141,277221,277307,277522,277743,277796-277797,277866,277889,277900,278139,278234-278235,278393,278395 /cfe/trunk/test:170344 /cfe/trunk/test/SemaTemplate:126920 Modified: cfe/branches/release_39/lib/Driver/ToolChains.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/branches/release_39/lib/Driver/ToolChains.cpp?rev=278605&r1=278604&r2=278605&view=diff ============================================================================== --- cfe/branches/release_39/lib/Driver/ToolChains.cpp (original) +++ cfe/branches/release_39/lib/Driver/ToolChains.cpp Sat Aug 13 15:43:56 2016 @@ -3281,6 +3281,19 @@ Tool *CloudABI::buildLinker() const { return new tools::cloudabi::Linker(*this); } +bool CloudABI::isPIEDefault() const { + // Only enable PIE on architectures that support PC-relative + // addressing. PC-relative addressing is required, as the process + // startup code must be able to relocate itself. + switch (getTriple().getArch()) { + case llvm::Triple::aarch64: + case llvm::Triple::x86_64: + return true; + default: + return false; + } +} + SanitizerMask CloudABI::getSupportedSanitizers() const { SanitizerMask Res = ToolChain::getSupportedSanitizers(); Res |= SanitizerKind::SafeStack; Modified: cfe/branches/release_39/lib/Driver/ToolChains.h URL: http://llvm.org/viewvc/llvm-project/cfe/branches/release_39/lib/Driver/ToolChains.h?rev=278605&r1=278604&r2=278605&view=diff ============================================================================== --- cfe/branches/release_39/lib/Driver/ToolChains.h (original) +++ cfe/branches/release_39/lib/Driver/ToolChains.h Sat Aug 13 15:43:56 2016 @@ -634,8 +634,7 @@ public: void AddCXXStdlibLibArgs(const llvm::opt::ArgList &Args, llvm::opt::ArgStringList &CmdArgs) const override; - bool isPIEDefault() const override { return true; } - + bool isPIEDefault() const override; SanitizerMask getSupportedSanitizers() const override; SanitizerMask getDefaultSanitizers() const override; Modified: cfe/branches/release_39/lib/Driver/Tools.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/branches/release_39/lib/Driver/Tools.cpp?rev=278605&r1=278604&r2=278605&view=diff ============================================================================== --- cfe/branches/release_39/lib/Driver/Tools.cpp (original) +++ cfe/branches/release_39/lib/Driver/Tools.cpp Sat Aug 13 15:43:56 2016 @@ -3258,7 +3258,7 @@ static bool shouldUseFramePointerForTarg break; } - if (Triple.isOSLinux()) { + if (Triple.isOSLinux() || Triple.getOS() == llvm::Triple::CloudABI) { switch (Triple.getArch()) { // Don't use a frame pointer on linux if optimizing for certain targets. case llvm::Triple::mips64: @@ -7458,11 +7458,13 @@ void cloudabi::Linker::ConstructJob(Comp // CloudABI only supports static linkage. CmdArgs.push_back("-Bstatic"); - - // CloudABI uses Position Independent Executables exclusively. - CmdArgs.push_back("-pie"); CmdArgs.push_back("--no-dynamic-linker"); - CmdArgs.push_back("-zrelro"); + + // Provide PIE linker flags in case PIE is default for the architecture. + if (ToolChain.isPIEDefault()) { + CmdArgs.push_back("-pie"); + CmdArgs.push_back("-zrelro"); + } CmdArgs.push_back("--eh-frame-hdr"); CmdArgs.push_back("--gc-sections"); Modified: cfe/branches/release_39/test/Driver/cloudabi.c URL: http://llvm.org/viewvc/llvm-project/cfe/branches/release_39/test/Driver/cloudabi.c?rev=278605&r1=278604&r2=278605&view=diff ============================================================================== --- cfe/branches/release_39/test/Driver/cloudabi.c (original) +++ cfe/branches/release_39/test/Driver/cloudabi.c Sat Aug 13 15:43:56 2016 @@ -1,8 +1,14 @@ // RUN: %clang %s -### -target x86_64-unknown-cloudabi 2>&1 | FileCheck %s -check-prefix=SAFESTACK // SAFESTACK: "-cc1" "-triple" "x86_64-unknown-cloudabi" {{.*}} "-ffunction-sections" "-fdata-sections" {{.*}} "-fsanitize=safe-stack" -// SAFESTACK: "-Bstatic" "-pie" "--no-dynamic-linker" "-zrelro" "--eh-frame-hdr" "--gc-sections" "-o" "a.out" "crt0.o" "crtbegin.o" "{{.*}}" "{{.*}}" "-lc" "-lcompiler_rt" "crtend.o" +// SAFESTACK: "-Bstatic" "--no-dynamic-linker" "-pie" "-zrelro" "--eh-frame-hdr" "--gc-sections" "-o" "a.out" "crt0.o" "crtbegin.o" "{{.*}}" "{{.*}}" "-lc" "-lcompiler_rt" "crtend.o" // RUN: %clang %s -### -target x86_64-unknown-cloudabi -fno-sanitize=safe-stack 2>&1 | FileCheck %s -check-prefix=NOSAFESTACK // NOSAFESTACK: "-cc1" "-triple" "x86_64-unknown-cloudabi" {{.*}} "-ffunction-sections" "-fdata-sections" // NOSAFESTACK-NOT: "-fsanitize=safe-stack" -// NOSAFESTACK: "-Bstatic" "-pie" "--no-dynamic-linker" "-zrelro" "--eh-frame-hdr" "--gc-sections" "-o" "a.out" "crt0.o" "crtbegin.o" "{{.*}}" "{{.*}}" "-lc" "-lcompiler_rt" "crtend.o" +// NOSAFESTACK: "-Bstatic" "--no-dynamic-linker" "-pie" "-zrelro" "--eh-frame-hdr" "--gc-sections" "-o" "a.out" "crt0.o" "crtbegin.o" "{{.*}}" "{{.*}}" "-lc" "-lcompiler_rt" "crtend.o" + +// PIE shouldn't be enabled on i686. Just on architectures that provide +// PC-relative addressing. +// RUN: %clang %s -### -target i686-unknown-cloudabi 2>&1 | FileCheck %s -check-prefix=NOPIE +// NOPIE: "-cc1" "-triple" "i686-unknown-cloudabi" {{.*}} "-ffunction-sections" "-fdata-sections" {{.*}} "-fsanitize=safe-stack" +// NOPIE: "-Bstatic" "--no-dynamic-linker" "--eh-frame-hdr" "--gc-sections" "-o" "a.out" "crt0.o" "crtbegin.o" "{{.*}}" "{{.*}}" "-lc" "-lcompiler_rt" "crtend.o" Modified: cfe/branches/release_39/test/Driver/cloudabi.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/branches/release_39/test/Driver/cloudabi.cpp?rev=278605&r1=278604&r2=278605&view=diff ============================================================================== --- cfe/branches/release_39/test/Driver/cloudabi.cpp (original) +++ cfe/branches/release_39/test/Driver/cloudabi.cpp Sat Aug 13 15:43:56 2016 @@ -1,8 +1,14 @@ // RUN: %clangxx %s -### -target x86_64-unknown-cloudabi 2>&1 | FileCheck %s -check-prefix=SAFESTACK // SAFESTACK: "-cc1" "-triple" "x86_64-unknown-cloudabi" {{.*}} "-ffunction-sections" "-fdata-sections" {{.*}} "-fsanitize=safe-stack" -// SAFESTACK: "-Bstatic" "-pie" "--no-dynamic-linker" "-zrelro" "--eh-frame-hdr" "--gc-sections" "-o" "a.out" "crt0.o" "crtbegin.o" "{{.*}}" "{{.*}}" "-lc++" "-lc++abi" "-lunwind" "-lc" "-lcompiler_rt" "crtend.o" +// SAFESTACK: "-Bstatic" "--no-dynamic-linker" "-pie" "-zrelro" "--eh-frame-hdr" "--gc-sections" "-o" "a.out" "crt0.o" "crtbegin.o" "{{.*}}" "{{.*}}" "-lc++" "-lc++abi" "-lunwind" "-lc" "-lcompiler_rt" "crtend.o" -// RUN: %clangxx %s -### -target x86_64-unknown-cloudabi -fno-sanitize=safe-stack 2>&1 | FileCheck %s -check-prefix=NOSAFESTACk +// RUN: %clangxx %s -### -target x86_64-unknown-cloudabi -fno-sanitize=safe-stack 2>&1 | FileCheck %s -check-prefix=NOSAFESTACK // NOSAFESTACK: "-cc1" "-triple" "x86_64-unknown-cloudabi" {{.*}} "-ffunction-sections" "-fdata-sections" // NOSAFESTACK-NOT: "-fsanitize=safe-stack" -// NOSAFESTACk: "-Bstatic" "-pie" "--no-dynamic-linker" "-zrelro" "--eh-frame-hdr" "--gc-sections" "-o" "a.out" "crt0.o" "crtbegin.o" "{{.*}}" "{{.*}}" "-lc++" "-lc++abi" "-lunwind" "-lc" "-lcompiler_rt" "crtend.o" +// NOSAFESTACK: "-Bstatic" "--no-dynamic-linker" "-pie" "-zrelro" "--eh-frame-hdr" "--gc-sections" "-o" "a.out" "crt0.o" "crtbegin.o" "{{.*}}" "{{.*}}" "-lc++" "-lc++abi" "-lunwind" "-lc" "-lcompiler_rt" "crtend.o" + +// PIE shouldn't be enabled on i686. Just on architectures that provide +// PC-relative addressing. +// RUN: %clangxx %s -### -target i686-unknown-cloudabi 2>&1 | FileCheck %s -check-prefix=NOPIE +// NOPIE: "-cc1" "-triple" "i686-unknown-cloudabi" {{.*}} "-ffunction-sections" "-fdata-sections" {{.*}} "-fsanitize=safe-stack" +// NOPIE: "-Bstatic" "--no-dynamic-linker" "--eh-frame-hdr" "--gc-sections" "-o" "a.out" "crt0.o" "crtbegin.o" "{{.*}}" "{{.*}}" "-lc++" "-lc++abi" "-lunwind" "-lc" "-lcompiler_rt" "crtend.o" Modified: cfe/branches/release_39/test/Driver/frame-pointer-elim.c URL: http://llvm.org/viewvc/llvm-project/cfe/branches/release_39/test/Driver/frame-pointer-elim.c?rev=278605&r1=278604&r2=278605&view=diff ============================================================================== --- cfe/branches/release_39/test/Driver/frame-pointer-elim.c (original) +++ cfe/branches/release_39/test/Driver/frame-pointer-elim.c Sat Aug 13 15:43:56 2016 @@ -8,6 +8,15 @@ // RUN: FileCheck --check-prefix=LINUX %s // LINUX-NOT: "-momit-leaf-frame-pointer" +// CloudABI follows the same rules as Linux. +// RUN: %clang -### -target x86_64-unknown-cloudabi -S -O1 %s 2>&1 | \ +// RUN: FileCheck --check-prefix=CLOUDABI-OPT %s +// CLOUDABI-OPT: "-momit-leaf-frame-pointer" + +// RUN: %clang -### -target x86_64-unknown-cloudabi -S %s 2>&1 | \ +// RUN: FileCheck --check-prefix=CLOUDABI %s +// CLOUDABI-NOT: "-momit-leaf-frame-pointer" + // Darwin disables omitting the leaf frame pointer even under optimization // unless the command lines are given. // RUN: %clang -### -target i386-apple-darwin -S %s 2>&1 | \ _______________________________________________ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits