Details
- Reviewers
MaskRay - Commits
- rG60bed4ab57d5: Replace deprecated %T in 2 tests.
Diff Detail
Event Timeline
If you do this, testroot-riscv64-baremetal-nogcc/ is probably also not useful (or you can replace it with a shorter string`.
Can you fix the tests when gcc-riscv64-linux-gnu is installed?
My build directory is /tmp/RelA. After sudo apt install gcc-10-riscv64-linux-gnu,
(note /usr/lib/gcc-cross/riscv64-linux-gnu/10 in the output, it should not be there if proper --sysroot is set)
% /tmp/RelA/bin/llvm-lit -vv riscv32-toolchain-extra.c ... Exit Code: 1 Command Output (stderr): -- /home/ray/llvm/clang/test/Driver/riscv32-toolchain-extra.c:28:34: error: C-RV32-BAREMETAL-ILP32-NOGCC: expected string not found in input // C-RV32-BAREMETAL-ILP32-NOGCC: "-internal-isystem" "{{.*}}Output/testroot-riscv32-baremetal-nogcc/bin/../riscv32-unknown-elf/include" ^ <stdin>:1:1: note: scanning from here clang version 12.0.0 ^ <stdin>:6:7: note: possible intended match here "/tmp/RelA/tools/clang/test/Driver/Output/testroot-riscv32-baremetal-nogcc/bin/riscv32-unknown-elf-ld" "-m" "elf32lriscv" "crt0.o" "/usr/lib/gcc-cross/riscv64-linux-gnu/10/crtbegin.o" "-L/usr/lib/gcc-cross/riscv64-linux-gnu/10" "-L/usr/lib/gcc-cross/riscv64-linux-gnu/10/../../../../riscv64-linux-gnu/lib" "/tmp/riscv32-toolchain-extra-527779.o" "--start-group" "-lc" "-lgloss" "--end-group" "-lgcc" "/usr/lib/gcc-cross/riscv64-linux-gnu/10/crtend.o" "-o" "a.out" ^ Input file: <stdin> Check file: /home/ray/llvm/clang/test/Driver/riscv32-toolchain-extra.c -dump-input=help explains the following input dump. Input was: <<<<<< 1: clang version 12.0.0 check:28'0 X~~~~~~~~~~~~~~~~~~~ error: no match found 2: Target: riscv32-unknown-unknown-elf check:28'0 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3: Thread model: posix check:28'0 ~~~~~~~~~~~~~~~~~~~ 4: InstalledDir: /tmp/RelA/tools/clang/test/Driver/Output/testroot-riscv32-baremetal-nogcc/bin check:28'0 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5: "/tmp/RelA/tools/clang/test/Driver/Output/testroot-riscv32-baremetal-nogcc/bin/clang" "-cc1" "-triple" "riscv32-unknown-unknown-elf" "-emit-obj" "-mrelax-all" "--mrelax-relocations" "-disable-free" "-main-file-name" "riscv32-toolchain-extra.c" "-mrelocation-model" "static" "-mframe-pointer=all" "-fmath-errno" "-fno-rounding-math" "-mconstructor-aliases" "-nostdsysteminc" "-target-feature" "+m" "-target-feature" "+a" "-target-feature" "+c" "-target-feature" "+relax" "-target-feature" "-save-restore" "-target-abi" "ilp32" "-msmall-data-limit" "8" "-fno-split-dwarf-inlining" "-debugger-tuning=gdb" "-resource-dir" "/tmp/RelA/tools/clang/test/Driver/Output/testroot-riscv32-baremetal-nogcc/lib/clang/12.0.0" "-internal-isystem" "/usr/lib/gcc-cross/riscv64-linux-gnu/10/../../../../riscv64-linux-gnu/include" "-fdebug-compilation-dir" "/tmp/RelA/tools/clang/test/Driver" "-ferror-limit" "19" "-fno-signed-char" "-fgnuc-version=4.2.1" "-faddrsig" "-o" "/tmp/riscv32-toolchain-extra-527779.o" "-x" "c" "/home/ray/llvm/clang/test/Driver/riscv32-toolchain-extra.c" check:28'0 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6: "/tmp/RelA/tools/clang/test/Driver/Output/testroot-riscv32-baremetal-nogcc/bin/riscv32-unknown-elf-ld" "-m" "elf32lriscv" "crt0.o" "/usr/lib/gcc-cross/riscv64-linux-gnu/10/crtbegin.o" "-L/usr/lib/gcc-cross/riscv64-linux-gnu/10" "-L/usr/lib/gcc-cross/riscv64-linux-gnu/10/../../../../riscv64-linux-gnu/lib" "/tmp/riscv32-toolchain-extra-527779.o" "--start-group" "-lc" "-lgloss" "--end-group" "-lgcc" "/usr/lib/gcc-cross/riscv64-linux-gnu/10/crtend.o" "-o" "a.out" check:28'0 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ check:28'1 ? possible intended match >>>>>> -- ******************** ******************** Failed Tests (1): Clang :: Driver/riscv32-toolchain-extra.c
riscv64-toolchain-extra is similar.
It seems that testcase I added has brought to surface a hidden issue. If you
look at the end of Generic_GCC::GCCInstallationDetector::AddDefaultGCCPrefixes,
it adds sysroot/usr to the Prefixes. If the sysroot is empty, this will end up
using the toolchain that you installed in /usr.
This code path is only taken if --gcc-toolchain is empty (or not given). The
mips-reduced-toolchain.cpp is a good example as testcase is dependent on this
behavior. If user provides a non-empty gcc-toolchain path, even if that path is
non-existent, this code path is not taken. This is why riscv32-toolchain-extra.c
did not fail before because it used an invalid path and not empty path for
--gcc-toolchain.
As a result of this behavior, if the user of RISCVToolChain does not provide a
--gcc-toolchain, what happens is dependent of whether user had a riscv
toolchain in /usr directory.
- If a toolchain was present then clang will pick it
- Otherwise clang will try clang_dir/../ (see RISCVToolChain::computeSysRoot())
For cross toolchains, this seems fragile to me. In this case, clang is picking
runtime bits from a riscv64-linux-gnu for riscv32/64-unknown-elf target. This
may cause difficult to debug problem.
I would wait for users of RISCVToolChain to comment if this is expected behavior.
If yes then I can probably update the test on the pattern of mips-reduced-toolchain.cpp.
Changes in this version.
- Added an explicit --sysroot argument.
- Shortened "testroot-riscv{len}-baremetal-nogcc" string
As pointed out by @MaskRay that some tests were failing when gcc-10-riscv64-linux-gnu was installed. This was happening because the test was checking a case when --gcc-toolchain is not provided. In this case, code does check the path alongside clang installation. But it also checks for a system wide installation in /usr. It prefers a higher version number too. So to make the test more robust, I have provided an explicit --sysroot argument. Its value has been chosen to match the existing pattern.