Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build system: support wrong target triples with LLVM #15986

Merged
merged 1 commit into from
Feb 11, 2021

Conversation

maribu
Copy link
Member

@maribu maribu commented Feb 11, 2021

Contribution description

clang/LLVM is a bit more finicky with what target triples it accepts compared
to GCC. However, the GCC target triple is needed to properly locate the C
libraries. In case a locally installed GCC toolchain uses a technically not
fully correct target triple, it might be impossible to build with LLVM.

The solution here is to allow specifying a TARGET_ARCH_LLVM target triple
(which defaults to TARGET_ARCH), which is passed to clang. For locating the
C lib, still TARGET_ARCH is used.

Testing procedure

Murdock will do.

Issues/PRs references

#15176

@maribu maribu added Area: build system Area: Build system Type: enhancement The issue suggests enhanceable parts / The PR enhances parts of the codebase / documentation labels Feb 11, 2021
@maribu maribu requested review from aabadie and benpicco February 11, 2021 16:18
clang/LLVM is a bit more finicky with what target triples it accepts compared
to GCC. However, the GCC target triple is needed to properly locate the C
libraries. In case a locally installed GCC toolchain uses a technically not
fully correct target triple, it might be impossible to build with LLVM.

The solution here is to allow specifying a TARGET_ARCH_LLVM target triple
(which defaults to TARGET_ARCH), which is passed to clang. For locating the
C lib, still TARGET_ARCH is used.
@maribu maribu force-pushed the llvm-target-tripple branch from f571750 to 6dcd3bb Compare February 11, 2021 16:19
@miri64
Copy link
Member

miri64 commented Feb 11, 2021

Murdock will do.

Will it? It currently does not build for LLVM ;-)

@miri64 miri64 added the CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR label Feb 11, 2021
@maribu
Copy link
Member Author

maribu commented Feb 11, 2021

Will it? It currently does not build for LLVM ;-)

Ah yes. We should do something about that :/

Copy link
Member

@miri64 miri64 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the meantime I "emulated" Murdock LLVM builds on my laptop (hello-world for newlib, gnrc_minimal for picolib, when supported)

(My laptop)
Operating System Environment
----------------------------
         Operating System: "Arch Linux" 
                   Kernel: Linux 5.10.14-arch1-1 x86_64 unknown
             System shell: GNU bash, version 5.1.4(1)-release (x86_64-pc-linux-gnu)
             make's shell: GNU bash, version 5.1.4(1)-release (x86_64-pc-linux-gnu)

Installed compiler toolchains
-----------------------------
               native gcc: gcc (GCC) 10.2.0
        arm-none-eabi-gcc: arm-none-eabi-gcc (Arch Repository) 10.2.0
                  avr-gcc: avr-gcc (GCC) 10.2.0
         mips-mti-elf-gcc: missing
           msp430-elf-gcc: missing
       riscv-none-elf-gcc: missing
  riscv64-unknown-elf-gcc: missing
     riscv-none-embed-gcc: missing
     xtensa-esp32-elf-gcc: missing
   xtensa-esp8266-elf-gcc: missing
                    clang: clang version 11.0.1

Installed compiler libs
-----------------------
     arm-none-eabi-newlib: "4.1.0"
      mips-mti-elf-newlib: missing
        msp430-elf-newlib: missing
    riscv-none-elf-newlib: missing
riscv64-unknown-elf-newlib: missing
  riscv-none-embed-newlib: missing
  xtensa-esp32-elf-newlib: missing
xtensa-esp8266-elf-newlib: missing
                 avr-libc: "2.0.0" ("20150208")

Installed development tools
---------------------------
                   ccache: ccache version 4.2
                    cmake: cmake version 3.19.4
                 cppcheck: Cppcheck 2.3
                  doxygen: 1.9.1
                      git: git version 2.30.1
                     make: GNU Make 4.3
                  openocd: Open On-Chip Debugger 0.10.0+dev-01089-g3bfe49266 (2020-02-26-14:18)
                   python: Python 3.9.1
                  python2: Python 2.7.18
                  python3: Python 3.9.1
                   flake8: 3.8.4 (mccabe: 0.6.1, pycodestyle: 2.6.0, pyflakes: 2.2.0) CPython 3.9.1 on
               coccinelle: spatch version 1.0.8 compiled with OCaml version 4.11.1
export RIOT_CI_BUILD=1
export TOOLCHAIN=llvm
for board in $(grep "^#: \${TEST_BOARDS_LLVM_COMPILE:=" .murdock | \
               cut -d= -f2 | tr -d '"' | tr -d '}')
do
    BOARD=${board} make -C examples/gnrc_minimal --no-print-directory -j clean all && \
    BOARD=${board} make -C examples/hello-world --no-print-directory -j clean all || \
    break
done
and it passes.
Building application "gnrc_minimal" for "iotlab-m3" with MCU "stm32".

   text	   data	    bss	    dec	    hex	filename
  38772	    120	   6572	  45464	   b198	/home/mlenders/Repositories/RIOT-OS/RIOT/examples/gnrc_minimal/bin/iotlab-m3/gnrc_minimal.elf
Building application "hello-world" for "iotlab-m3" with MCU "stm32".

   text	   data	    bss	    dec	    hex	filename
   9064	    112	   2300	  11476	   2cd4	/home/mlenders/Repositories/RIOT-OS/RIOT/examples/hello-world/bin/iotlab-m3/hello-world.elf
Building application "gnrc_minimal" for "native" with MCU "native".

/usr/bin/ld: /home/mlenders/Repositories/RIOT-OS/RIOT/examples/gnrc_minimal/bin/native/cpu/tramp.o: warning: relocation against `_native_saved_eip' in read-only section `.text'
/usr/bin/ld: warning: creating DT_TEXTREL in a PIE
   text	   data	    bss	    dec	    hex	filename
 112928	    920	  68104	 181952	  2c6c0	/home/mlenders/Repositories/RIOT-OS/RIOT/examples/gnrc_minimal/bin/native/gnrc_minimal.elf
Building application "hello-world" for "native" with MCU "native".

/usr/bin/ld: /home/mlenders/Repositories/RIOT-OS/RIOT/examples/hello-world/bin/native/cpu/tramp.o: warning: relocation against `_native_saved_eip' in read-only section `.text'
/usr/bin/ld: warning: creating DT_TEXTREL in a PIE
   text	   data	    bss	    dec	    hex	filename
  28217	    756	  47644	  76617	  12b49	/home/mlenders/Repositories/RIOT-OS/RIOT/examples/hello-world/bin/native/hello-world.elf
rm -rf /home/mlenders/Repositories/RIOT-OS/RIOT/examples/gnrc_minimal/bin/nrf52dk/pkg-build/nimble
Building application "gnrc_minimal" for "nrf52dk" with MCU "nrf52".

"make" -C /home/mlenders/Repositories/RIOT-OS/RIOT/build/pkg/nimble/nimble/controller/src/ -f /home/mlenders/Repositories/RIOT-OS/RIOT/Makefile.base MODULE=nimble_controller
"make" -C /home/mlenders/Repositories/RIOT-OS/RIOT/build/pkg/nimble/nimble/drivers/nrf52/src/ -f /home/mlenders/Repositories/RIOT-OS/RIOT/Makefile.base MODULE=nimble_drivers_nrf5x
"make" -C /home/mlenders/Repositories/RIOT-OS/RIOT/build/pkg/nimble/nimble/host/src/ -f /home/mlenders/Repositories/RIOT-OS/RIOT/pkg/nimble/nimble.host.mk
"make" -C /home/mlenders/Repositories/RIOT-OS/RIOT/build/pkg/nimble/nimble/host/store/ram/src/ -f /home/mlenders/Repositories/RIOT-OS/RIOT/Makefile.base MODULE=nimble_host_store_ram
"make" -C /home/mlenders/Repositories/RIOT-OS/RIOT/build/pkg/nimble/nimble/host/util/src/ -f /home/mlenders/Repositories/RIOT-OS/RIOT/Makefile.base MODULE=nimble_host_util
"make" -C /home/mlenders/Repositories/RIOT-OS/RIOT/pkg/nimble/netif/
"make" -C /home/mlenders/Repositories/RIOT-OS/RIOT/build/pkg/nimble/porting/npl/riot/src/ -f /home/mlenders/Repositories/RIOT-OS/RIOT/Makefile.base MODULE=nimble_npl_riot
"make" -C /home/mlenders/Repositories/RIOT-OS/RIOT/build/pkg/nimble/porting/nimble/src/ -f /home/mlenders/Repositories/RIOT-OS/RIOT/Makefile.base MODULE=nimble_porting_nimble
"make" -C /home/mlenders/Repositories/RIOT-OS/RIOT/pkg/nimble/contrib/
"make" -C /home/mlenders/Repositories/RIOT-OS/RIOT/build/pkg/nimble/nimble/host/services/ipss/src/ -f /home/mlenders/Repositories/RIOT-OS/RIOT/Makefile.base MODULE=nimble_svc_ipss
"make" -C /home/mlenders/Repositories/RIOT-OS/RIOT/build/pkg/nimble/ext/tinycrypt/src/ -f /home/mlenders/Repositories/RIOT-OS/RIOT/Makefile.base MODULE=nimble_tinycrypt
"make" -C /home/mlenders/Repositories/RIOT-OS/RIOT/build/pkg/nimble/nimble/transport/ram/src/ -f /home/mlenders/Repositories/RIOT-OS/RIOT/Makefile.base MODULE=nimble_transport_ram
   text	   data	    bss	    dec	    hex	filename
 110724	    228	  32540	 143492	  23084	/home/mlenders/Repositories/RIOT-OS/RIOT/examples/gnrc_minimal/bin/nrf52dk/gnrc_minimal.elf
Building application "hello-world" for "nrf52dk" with MCU "nrf52".

   text	   data	    bss	    dec	    hex	filename
   8788	    108	   2308	  11204	   2bc4	/home/mlenders/Repositories/RIOT-OS/RIOT/examples/hello-world/bin/nrf52dk/hello-world.elf
Building application "gnrc_minimal" for "mulle" with MCU "kinetis".

   text	   data	    bss	    dec	    hex	filename
  47144	    260	   7452	  54856	   d648	/home/mlenders/Repositories/RIOT-OS/RIOT/examples/gnrc_minimal/bin/mulle/gnrc_minimal.elf
Building application "hello-world" for "mulle" with MCU "kinetis".

   text	   data	    bss	    dec	    hex	filename
  19576	    252	   2828	  22656	   5880	/home/mlenders/Repositories/RIOT-OS/RIOT/examples/hello-world/bin/mulle/hello-world.elf
Building application "gnrc_minimal" for "nucleo-f401re" with MCU "stm32".

   text	   data	    bss	    dec	    hex	filename
  29556	    120	   4116	  33792	   8400	/home/mlenders/Repositories/RIOT-OS/RIOT/examples/gnrc_minimal/bin/nucleo-f401re/gnrc_minimal.elf
Building application "hello-world" for "nucleo-f401re" with MCU "stm32".

   text	   data	    bss	    dec	    hex	filename
   9544	    112	   2312	  11968	   2ec0	/home/mlenders/Repositories/RIOT-OS/RIOT/examples/hello-world/bin/nucleo-f401re/hello-world.elf
Building application "gnrc_minimal" for "samr21-xpro" with MCU "samd21".

   text	   data	    bss	    dec	    hex	filename
  40052	    120	   6564	  46736	   b690	/home/mlenders/Repositories/RIOT-OS/RIOT/examples/gnrc_minimal/bin/samr21-xpro/gnrc_minimal.elf
Building application "hello-world" for "samr21-xpro" with MCU "samd21".

   text	   data	    bss	    dec	    hex	filename
   8792	    112	   2292	  11196	   2bbc	/home/mlenders/Repositories/RIOT-OS/RIOT/examples/hello-world/bin/samr21-xpro/hello-world.elf
rm -rf /home/mlenders/Repositories/RIOT-OS/RIOT/examples/gnrc_minimal/bin/slstk3402a/pkg-build/gecko_sdk
Building application "gnrc_minimal" for "slstk3402a" with MCU "efm32".

[INFO] cloning gecko_sdk
Cloning into '/home/mlenders/Repositories/RIOT-OS/RIOT/build/pkg/gecko_sdk'...
remote: Enumerating objects: 224, done.
remote: Counting objects: 100% (224/224), done.
remote: Compressing objects: 100% (74/74), done.
remote: Total 1682 (delta 192), reused 166 (delta 149), pack-reused 1458
Receiving objects: 100% (1682/1682), 11.05 MiB | 2.42 MiB/s, done.
Resolving deltas: 100% (1303/1303), done.
HEAD is now at b47581a Regenerated files.
[INFO] updating gecko_sdk /home/mlenders/Repositories/RIOT-OS/RIOT/build/pkg/gecko_sdk/.pkg-state.git-downloaded
echo b47581a678a53c01dacea9a0a3956c67854b12f4 > /home/mlenders/Repositories/RIOT-OS/RIOT/build/pkg/gecko_sdk/.pkg-state.git-downloaded
[INFO] patch gecko_sdk
"make" -C /home/mlenders/Repositories/RIOT-OS/RIOT/build/pkg/gecko_sdk/dist
   text	   data	    bss	    dec	    hex	filename
  37704	    140	   4132	  41976	   a3f8	/home/mlenders/Repositories/RIOT-OS/RIOT/examples/gnrc_minimal/bin/slstk3402a/gnrc_minimal.elf
rm -rf /home/mlenders/Repositories/RIOT-OS/RIOT/examples/hello-world/bin/slstk3402a/pkg-build/gecko_sdk
Building application "hello-world" for "slstk3402a" with MCU "efm32".

"make" -C /home/mlenders/Repositories/RIOT-OS/RIOT/build/pkg/gecko_sdk/dist
   text	   data	    bss	    dec	    hex	filename
  16444	    132	   2316	  18892	   49cc	/home/mlenders/Repositories/RIOT-OS/RIOT/examples/hello-world/bin/slstk3402a/hello-world.elf

@miri64 miri64 merged commit 2991466 into RIOT-OS:master Feb 11, 2021
@maribu maribu deleted the llvm-target-tripple branch March 31, 2021 08:02
@kaspar030 kaspar030 added this to the Release 2021.04 milestone Apr 23, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: build system Area: Build system CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR Type: enhancement The issue suggests enhanceable parts / The PR enhances parts of the codebase / documentation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants