Unable to build for native - ld and objcopy warnings

Hi!

I’m assuming there is some error in my toolchain as I’m struggeling to build any of the examples on native, however I’m able to build them just fine using docker. For various reasons, I unfortunately need to be able to build the project on native.

This is the specific error I’m getting:

/usr/bin/ld: warning: /home/alf/Skole/master/RIOT/examples/default/bin/native/default.elf has a LOAD segment with RWX permissions
/usr/local/bin/objcopy: Unable to recognise the format of the input file `/home/alf/Skole/master/RIOT/examples/default/bin/native/default.elf'
make: *** [/home/alf/Skole/master/RIOT/examples/default/../../Makefile.include:763: /home/alf/Skole/master/RIOT/examples/default/bin/native/default.bin] Error 1

I’m building on arch, and I’ve installed all the dependencies outlined 1 and 2

I’ve tried compiling various examples in both the master branch and 2022.07.

Any input on what the next steps would be?

Diagnostics time:

can you show the command you used to build? I would guess something like

make all -C examples/default

Next show you toolchain setup info:

make print-versions

and finally maybe just some info of the bin directory since it seems like some strange permission error

ls -al /home/alf/Skole/master/RIOT/examples/default/bin/native/

As for the toolchain setup, there is a potentially out-of-date script in dist/tools/vagrant/ that can help, otherwise look at what docker does.

I’m in the ecamples/default directory and simply running make all term. Running make all produces the same results.

make print-versions:

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

Installed compiler toolchains
-----------------------------
               native gcc: gcc (GCC) 12.2.0
        arm-none-eabi-gcc: arm-none-eabi-gcc (Arch Repository) 12.2.0
                  avr-gcc: missing
         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 14.0.6

Installed compiler libs
-----------------------
     arm-none-eabi-newlib: "4.2.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: missing (missing)

Installed development tools
---------------------------
                   ccache: ccache version 4.6.3
                    cmake: cmake version 3.24.2
                 cppcheck: Cppcheck 2.9
                  doxygen: 1.9.3
                      git: git version 2.38.0
                     make: GNU Make 4.3
                  openocd: Open On-Chip Debugger 0.11.0
                   python: Python 3.10.7
                  python2: Python 2.7.18
                  python3: Python 3.10.7
                   flake8: 5.0.4 (mccabe: 0.7.0, pycodestyle: 2.9.1, pyflakes: 2.5.0) CPython 3.10.7 on
               coccinelle: missing


ls -al /home/alf/Skole/master/RIOT/examples/default/bin/native/:

total 3228
drwxr-xr-x 48 alf alf    4096 Oct  6 20:58 ./
drwxr-xr-x  3 alf alf    4096 Oct  6 20:57 ../
drwxr-xr-x  2 alf alf    4096 Oct  6 20:57 application_default/
drwxr-xr-x  2 alf alf    4096 Oct  6 20:57 auto_init/
drwxr-xr-x  2 alf alf    4096 Oct  6 20:57 board/
drwxr-xr-x  2 alf alf    4096 Oct  6 20:57 board_common_init/
drwxr-xr-x  2 alf alf    4096 Oct  6 20:57 core/
drwxr-xr-x  2 alf alf    4096 Oct  6 20:57 core_lib/
drwxr-xr-x  2 alf alf    4096 Oct  6 20:57 cpu/
-rwxr-xr-x  1 alf alf 1112452 Oct  6 20:58 default.elf*
-rw-r--r--  1 alf alf 1992526 Oct  6 20:58 default.map
drwxr-xr-x  2 alf alf    4096 Oct  6 20:57 drivers/
drwxr-xr-x  2 alf alf    4096 Oct  6 20:57 eui_provider/
drwxr-xr-x  2 alf alf    4096 Oct  6 20:57 event/
drwxr-xr-x  2 alf alf    4096 Oct  6 20:57 fmt/
drwxr-xr-x  2 alf alf    4096 Oct  6 20:57 frac/
drwxr-xr-x  2 alf alf    4096 Oct  6 20:57 gnrc/
drwxr-xr-x  2 alf alf    4096 Oct  6 20:57 gnrc_netapi/
drwxr-xr-x  2 alf alf    4096 Oct  6 20:57 gnrc_netif/
drwxr-xr-x  2 alf alf    4096 Oct  6 20:57 gnrc_netif_ethernet/
drwxr-xr-x  2 alf alf    4096 Oct  6 20:57 gnrc_netif_hdr/
drwxr-xr-x  2 alf alf    4096 Oct  6 20:57 gnrc_netif_init_devs/
drwxr-xr-x  2 alf alf    4096 Oct  6 20:57 gnrc_netreg/
drwxr-xr-x  2 alf alf    4096 Oct  6 20:57 gnrc_pkt/
drwxr-xr-x  2 alf alf    4096 Oct  6 20:57 gnrc_pktbuf/
drwxr-xr-x  2 alf alf    4096 Oct  6 20:57 gnrc_pktbuf_static/
drwxr-xr-x  2 alf alf    4096 Oct  6 20:57 gnrc_pktdump/
drwxr-xr-x  2 alf alf    4096 Oct  6 20:57 iolist/
drwxr-xr-x  2 alf alf    4096 Oct  6 20:57 l2util/
drwxr-xr-x  2 alf alf    4096 Oct  6 20:57 luid/
drwxr-xr-x  2 alf alf    4096 Oct  6 20:57 native_cli_eui_provider/
drwxr-xr-x  2 alf alf    4096 Oct  6 20:57 native_drivers/
drwxr-xr-x  2 alf alf    4096 Oct  6 20:57 netdev/
drwxr-xr-x  2 alf alf    4096 Oct  6 20:57 netdev_tap/
drwxr-xr-x  2 alf alf    4096 Oct  6 20:57 netif/
drwxr-xr-x  2 alf alf    4096 Oct  6 20:57 od/
drwxr-xr-x  2 alf alf    4096 Oct  6 20:57 periph/
drwxr-xr-x  2 alf alf    4096 Oct  6 20:57 periph_common/
drwxr-xr-x  2 alf alf    4096 Oct  6 20:57 phydat/
drwxr-xr-x  2 alf alf    4096 Oct  6 20:57 ps/
drwxr-xr-x  2 alf alf    4096 Oct  6 20:57 riotbuild/
drwxr-xr-x  2 alf alf    4096 Oct  6 20:57 rtc_utils/
drwxr-xr-x  2 alf alf    4096 Oct  6 20:57 saul/
drwxr-xr-x  2 alf alf    4096 Oct  6 20:57 saul_init_devs/
drwxr-xr-x  2 alf alf    4096 Oct  6 20:57 saul_reg/
drwxr-xr-x  2 alf alf    4096 Oct  6 20:57 shell/
drwxr-xr-x  2 alf alf    4096 Oct  6 20:57 shell_commands/
drwxr-xr-x  2 alf alf    4096 Oct  6 20:57 stdio_native/
drwxr-xr-x  2 alf alf    4096 Oct  6 20:57 sys/
drwxr-xr-x  2 alf alf    4096 Oct  6 20:57 ztimer_core/

I don’t believe the missing libs should matter since I’m trying to compile for native right?

Just for my own sanity can you run this:

objcopy -Obinary examples/default/bin/native/default.elf examples/default/bin/native/default.bin

I wonder if the linker warning is actually a problem…

I get the following result: objcopy: Unable to recognise the format of the input file 'examples/default/bin/native/default.elf'

I guess that would be the first problem to solve. I am not an arch user so I don’t think I can help that much…

This isn’t “RIOT” related but something with the toolchain, maybe google or stack overflow might be able to help with this. Otherwise try pinging some other maintainers.

What does running file examples/default/bin/native/default.elf show?

I’ll try to investigate my system a bit more. Might be some toolchain problems on my end that I haven’t been able to figure out.

examples/default/bin/native/default.elf: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), dynamically linked, interpreter /lib/ld-linux.so.2, BuildID[sha1]=66a3867226c9ae5c7ec10910b00aeabe72f0d01e, for GNU/Linux 3.2.0, with debug_info, not stripped

/usr/local/bin/objcopy: Unable to recognise the format of the input file /home/alf/Skole/master/RIOT/examples/default/bin/native/default.elf’`

That’s not the arch linux default objcopy, maybe it was compiled without 32bit support? Maybe try with /usr/bin/objcopy?

Wow, totally missed that. I removed that version of objcopy and the compilation now succeeds. Thanks a lot :slight_smile: