diff --git a/0001-ToolChain-Add-lgcc_s-to-the-linker-flags-when-using-.patch b/0001-ToolChain-Add-lgcc_s-to-the-linker-flags-when-using-.patch new file mode 100644 index 0000000..f4f0fa3 --- /dev/null +++ b/0001-ToolChain-Add-lgcc_s-to-the-linker-flags-when-using-.patch @@ -0,0 +1,50 @@ +From 09ae3ef5710a89505318ec721c65b6c838147276 Mon Sep 17 00:00:00 2001 +From: Tom Stellard +Date: Thu, 7 Feb 2019 21:05:37 -0800 +Subject: [PATCH] ToolChain: Add -lgcc_s to the linker flags when using libc++ + +The libc++ build for Fedora does not include an implementation of +libunwind, so we need to explicitly link against something that +provides this implementation. +--- + clang/lib/Driver/ToolChain.cpp | 1 + + clang/test/Driver/netbsd.cpp | 4 ++-- + 2 files changed, 3 insertions(+), 2 deletions(-) + +diff --git a/lib/Driver/ToolChain.cpp b/lib/Driver/ToolChain.cpp +index 88a627e..cb99844 100644 +--- a/lib/Driver/ToolChain.cpp ++++ b/lib/Driver/ToolChain.cpp +@@ -767,6 +767,7 @@ void ToolChain::AddCXXStdlibLibArgs(const ArgList &Args, + switch (Type) { + case ToolChain::CST_Libcxx: + CmdArgs.push_back("-lc++"); ++ CmdArgs.push_back("-lgcc_s"); + break; + + case ToolChain::CST_Libstdcxx: +diff --git a/test/Driver/netbsd.cpp b/test/Driver/netbsd.cpp +index 4af7d83..ff18c62 100644 +--- a/test/Driver/netbsd.cpp ++++ b/test/Driver/netbsd.cpp +@@ -131,7 +131,7 @@ + // ARM-7: clang{{.*}}" "-cc1" "-triple" "armv5e-unknown-netbsd7.0.0-eabi" + // ARM-7: ld{{.*}}" "--eh-frame-hdr" "-dynamic-linker" "/libexec/ld.elf_so" + // ARM-7: "-o" "a.out" "{{.*}}/usr/lib{{/|\\\\}}crt0.o" "{{.*}}/usr/lib{{/|\\\\}}eabi{{/|\\\\}}crti.o" +-// ARM-7: "{{.*}}/usr/lib{{/|\\\\}}crtbegin.o" "{{.*}}.o" "-lc++" "-lm" "-lc" ++// ARM-7: "{{.*}}/usr/lib{{/|\\\\}}crtbegin.o" "{{.*}}.o" "-lc++" "-lgcc_s" "-lm" "-lc" + // ARM-7: "{{.*}}/usr/lib{{/|\\\\}}crtend.o" "{{.*}}/usr/lib{{/|\\\\}}crtn.o" + + // AARCH64: clang{{.*}}" "-cc1" "-triple" "aarch64-unknown-netbsd" +@@ -250,7 +250,7 @@ + // S-ARM-7: clang{{.*}}" "-cc1" "-triple" "armv5e-unknown-netbsd7.0.0-eabi" + // S-ARM-7: ld{{.*}}" "--eh-frame-hdr" "-Bstatic" + // S-ARM-7: "-o" "a.out" "{{.*}}/usr/lib{{/|\\\\}}crt0.o" "{{.*}}/usr/lib{{/|\\\\}}eabi{{/|\\\\}}crti.o" +-// S-ARM-7: "{{.*}}/usr/lib{{/|\\\\}}crtbegin.o" "{{.*}}.o" "-lc++" "-lm" "-lc" ++// S-ARM-7: "{{.*}}/usr/lib{{/|\\\\}}crtbegin.o" "{{.*}}.o" "-lc++" "-lgcc_s" "-lm" "-lc" + // S-ARM-7: "{{.*}}/usr/lib{{/|\\\\}}crtend.o" "{{.*}}/usr/lib{{/|\\\\}}crtn.o" + + // S-AARCH64: clang{{.*}}" "-cc1" "-triple" "aarch64-unknown-netbsd" +-- +1.8.3.1 + diff --git a/clang.spec b/clang.spec index 571417e..138b761 100644 --- a/clang.spec +++ b/clang.spec @@ -61,7 +61,7 @@ Name: %pkg_name Version: %{maj_ver}.%{min_ver}.%{patch_ver} -Release: 0.2%{?rc_ver:.rc%{rc_ver}}%{?dist} +Release: 0.3%{?rc_ver:.rc%{rc_ver}}%{?dist} Summary: A C language family front-end for LLVM License: NCSA @@ -74,6 +74,7 @@ Source1: http://%{?rc_ver:pre}releases.llvm.org/%{version}/%{?rc_ver:rc%{rc_ver} Patch4: 0002-gtest-reorg.patch Patch9: 0001-Fix-uninitialized-value-in-ABIArgInfo.patch Patch10: 0001-Workaround-GCC-9-bug-when-handling-bitfields.patch +Patch11: 0001-ToolChain-Add-lgcc_s-to-the-linker-flags-when-using-.patch BuildRequires: gcc BuildRequires: gcc-c++ @@ -212,6 +213,7 @@ pathfix.py -i %{__python3} -pn \ %patch4 -p1 -b .gtest %patch9 -p1 -b .abi-arginfo %patch10 -p1 -b .bitfields +%patch11 -p1 -b .libcxx-fix mv ../%{clang_tools_srcdir} tools/extra @@ -414,6 +416,9 @@ false %endif %changelog +* Mon Feb 25 2019 tstellar@redhat.com - 8.0.0-0.3.rc2 +- Fix compiling with -stdlib=libc++ + * Thu Feb 21 2019 sguelton@redhat.com - 8.0.0-0.2.rc2 - 8.0.0 Release candidate 2 diff --git a/tests/llvm-toolchain/runtest.sh b/tests/llvm-toolchain/runtest.sh new file mode 100755 index 0000000..eeebda5 --- /dev/null +++ b/tests/llvm-toolchain/runtest.sh @@ -0,0 +1,29 @@ +#!/bin/sh + +# Tests for using a full LLVM toolchain: clang + compiler-rt + libcxx + lld + +set -ex pipefail + +# Test compile a C program. +cat << EOF | \ + clang -fuse-ld=lld -rtlib=compiler-rt -x c - && \ + ./a.out | grep 'Hello World' + +#include +int main(int argc, char **argv) { + printf("Hello World\n"); + return 0; +} +EOF + +# Test compile a C++ program. +cat << EOF | \ + clang++ -x c++ -fuse-ld=lld -rtlib=compiler-rt -stdlib=libc++ - && \ + ./a.out | grep 'Hello World' + +#include +int main(int argc, char **argv) { + std::cout << "Hello World\n"; + return 0; +} +EOF diff --git a/tests/tests.yml b/tests/tests.yml index 08d6d21..04a1f8f 100644 --- a/tests/tests.yml +++ b/tests/tests.yml @@ -8,6 +8,17 @@ - llvm-test-suite - ninja-build - gcc-x86_64-linux-gnu + # FIXME: It would be nice if we could only install dependencies for a + # single test rather than installing dependencies for all tests. This + # will help us catch bugs with implicit package dependencies e.g. + # package A depends on package B but does not have an explicit Requires. + # These are required for the llvm-toolchain test: + - clang + - lld + - compiler-rt + - libcxx-devel + - glibc-devel + - gcc tests: - rhbz#482491: dir: ./ @@ -16,3 +27,4 @@ - llvm-abi-test-suite - rhbz_1657544 - rhbz_1647130 + - llvm-toolchain