elixir-circuits / circuits_uart

Discover and use UARTs and serial ports in Elixir
Apache License 2.0
189 stars 48 forks source link

Compile error in Fedora 38 #155

Open antonie3007 opened 1 year ago

antonie3007 commented 1 year ago

Setup

'Development Tools' are installed.

iex -v
Erlang/OTP 25 [erts-13.2] [source] [64-bit] [smp:16:16] [ds:16:16:10] [async-threads:1] [jit:ns]

IEx 1.14.3 (compiled with Erlang/OTP 25)

Expected Behavior

Actual Behavior

 CC circuits_uart.o
 CC debug_tests.o
 CC erlcmd.o
 CC uart_comm.o
 CC uart_comm_unix.o
 CC uart_comm_win.o
 CC uart_enum.o
 CC uart_enum_linux.o
 CC uart_enum_osx.o
 CC uart_enum_win.o
 CC util.o
 LD circuits_uart
/usr/bin/ld: /usr/libexec/gcc/x86_64-redhat-linux/13/liblto_plugin.so: error loading plugin: /usr/libexec/gcc/x86_64-redhat-linux/13/liblto_plugin.so: verkeerde ELF-klasse: ELFCLASS64
collect2: fout: ld gaf exit-status 1 terug
make: *** [src/Makefile:111: /home/antonie/Projects/TrackTimer_V2.0/02-TrackTimer_Main_Module/02-tracktimer_server/elixir/tracktimer_2.0.x/_build/dev/lib/circuits_uart/priv/circuits_uart] Fout 1

Steps to Reproduce the Problem

fhunleth commented 1 year ago

Hi @antonie3007,

Could you run:

mix clean --deps
V=1 mix compile

I think that you may have CFLAGS or LDFLAGS defined in your environment and the value is getting used. The V=1 part will show what's being passed to gcc.

antonie3007 commented 1 year ago

Hi @fhunleth

Here is the result.

==> circuits_uart
mkdir -p /home/antonie/Projects/TrackTimer_V2.0/02-TrackTimer_Main_Module/02-tracktimer_server/elixir/tracktimer_2.0.3/_build/dev/lib/circuits_uart/priv
mkdir -p /home/antonie/Projects/TrackTimer_V2.0/02-TrackTimer_Main_Module/02-tracktimer_server/elixir/tracktimer_2.0.3/_build/dev/lib/circuits_uart/obj
mkdir -p /home/antonie/Projects/TrackTimer_V2.0/02-TrackTimer_Main_Module/02-tracktimer_server/elixir/tracktimer_2.0.3/_build/dev/lib/circuits_uart/obj/ei_copy
 CC circuits_uart.o
cc -c -I/usr/lib64/erlang/usr/include -O2 -Wall -Wextra -Wno-unused-parameter -std=c99 -D_GNU_SOURCE -o /home/antonie/Projects/TrackTimer_V2.0/02-TrackTimer_Main_Module/02-tracktimer_server/elixir/tracktimer_2.0.3/_build/dev/lib/circuits_uart/obj/circuits_uart.o src/circuits_uart.c
 CC debug_tests.o
cc -c -I/usr/lib64/erlang/usr/include -O2 -Wall -Wextra -Wno-unused-parameter -std=c99 -D_GNU_SOURCE -o /home/antonie/Projects/TrackTimer_V2.0/02-TrackTimer_Main_Module/02-tracktimer_server/elixir/tracktimer_2.0.3/_build/dev/lib/circuits_uart/obj/debug_tests.o src/debug_tests.c
 CC erlcmd.o
cc -c -I/usr/lib64/erlang/usr/include -O2 -Wall -Wextra -Wno-unused-parameter -std=c99 -D_GNU_SOURCE -o /home/antonie/Projects/TrackTimer_V2.0/02-TrackTimer_Main_Module/02-tracktimer_server/elixir/tracktimer_2.0.3/_build/dev/lib/circuits_uart/obj/erlcmd.o src/erlcmd.c
 CC uart_comm.o
cc -c -I/usr/lib64/erlang/usr/include -O2 -Wall -Wextra -Wno-unused-parameter -std=c99 -D_GNU_SOURCE -o /home/antonie/Projects/TrackTimer_V2.0/02-TrackTimer_Main_Module/02-tracktimer_server/elixir/tracktimer_2.0.3/_build/dev/lib/circuits_uart/obj/uart_comm.o src/uart_comm.c
 CC uart_comm_unix.o
cc -c -I/usr/lib64/erlang/usr/include -O2 -Wall -Wextra -Wno-unused-parameter -std=c99 -D_GNU_SOURCE -o /home/antonie/Projects/TrackTimer_V2.0/02-TrackTimer_Main_Module/02-tracktimer_server/elixir/tracktimer_2.0.3/_build/dev/lib/circuits_uart/obj/uart_comm_unix.o src/uart_comm_unix.c
 CC uart_comm_win.o
cc -c -I/usr/lib64/erlang/usr/include -O2 -Wall -Wextra -Wno-unused-parameter -std=c99 -D_GNU_SOURCE -o /home/antonie/Projects/TrackTimer_V2.0/02-TrackTimer_Main_Module/02-tracktimer_server/elixir/tracktimer_2.0.3/_build/dev/lib/circuits_uart/obj/uart_comm_win.o src/uart_comm_win.c
 CC uart_enum.o
cc -c -I/usr/lib64/erlang/usr/include -O2 -Wall -Wextra -Wno-unused-parameter -std=c99 -D_GNU_SOURCE -o /home/antonie/Projects/TrackTimer_V2.0/02-TrackTimer_Main_Module/02-tracktimer_server/elixir/tracktimer_2.0.3/_build/dev/lib/circuits_uart/obj/uart_enum.o src/uart_enum.c
 CC uart_enum_linux.o
cc -c -I/usr/lib64/erlang/usr/include -O2 -Wall -Wextra -Wno-unused-parameter -std=c99 -D_GNU_SOURCE -o /home/antonie/Projects/TrackTimer_V2.0/02-TrackTimer_Main_Module/02-tracktimer_server/elixir/tracktimer_2.0.3/_build/dev/lib/circuits_uart/obj/uart_enum_linux.o src/uart_enum_linux.c
 CC uart_enum_osx.o
cc -c -I/usr/lib64/erlang/usr/include -O2 -Wall -Wextra -Wno-unused-parameter -std=c99 -D_GNU_SOURCE -o /home/antonie/Projects/TrackTimer_V2.0/02-TrackTimer_Main_Module/02-tracktimer_server/elixir/tracktimer_2.0.3/_build/dev/lib/circuits_uart/obj/uart_enum_osx.o src/uart_enum_osx.c
 CC uart_enum_win.o
cc -c -I/usr/lib64/erlang/usr/include -O2 -Wall -Wextra -Wno-unused-parameter -std=c99 -D_GNU_SOURCE -o /home/antonie/Projects/TrackTimer_V2.0/02-TrackTimer_Main_Module/02-tracktimer_server/elixir/tracktimer_2.0.3/_build/dev/lib/circuits_uart/obj/uart_enum_win.o src/uart_enum_win.c
 CC util.o
cc -c -I/usr/lib64/erlang/usr/include -O2 -Wall -Wextra -Wno-unused-parameter -std=c99 -D_GNU_SOURCE -o /home/antonie/Projects/TrackTimer_V2.0/02-TrackTimer_Main_Module/02-tracktimer_server/elixir/tracktimer_2.0.3/_build/dev/lib/circuits_uart/obj/util.o src/util.c
 LD circuits_uart
cc /home/antonie/Projects/TrackTimer_V2.0/02-TrackTimer_Main_Module/02-tracktimer_server/elixir/tracktimer_2.0.3/_build/dev/lib/circuits_uart/obj/circuits_uart.o /home/antonie/Projects/TrackTimer_V2.0/02-TrackTimer_Main_Module/02-tracktimer_server/elixir/tracktimer_2.0.3/_build/dev/lib/circuits_uart/obj/debug_tests.o /home/antonie/Projects/TrackTimer_V2.0/02-TrackTimer_Main_Module/02-tracktimer_server/elixir/tracktimer_2.0.3/_build/dev/lib/circuits_uart/obj/erlcmd.o /home/antonie/Projects/TrackTimer_V2.0/02-TrackTimer_Main_Module/02-tracktimer_server/elixir/tracktimer_2.0.3/_build/dev/lib/circuits_uart/obj/uart_comm.o /home/antonie/Projects/TrackTimer_V2.0/02-TrackTimer_Main_Module/02-tracktimer_server/elixir/tracktimer_2.0.3/_build/dev/lib/circuits_uart/obj/uart_comm_unix.o /home/antonie/Projects/TrackTimer_V2.0/02-TrackTimer_Main_Module/02-tracktimer_server/elixir/tracktimer_2.0.3/_build/dev/lib/circuits_uart/obj/uart_comm_win.o /home/antonie/Projects/TrackTimer_V2.0/02-TrackTimer_Main_Module/02-tracktimer_server/elixir/tracktimer_2.0.3/_build/dev/lib/circuits_uart/obj/uart_enum.o /home/antonie/Projects/TrackTimer_V2.0/02-TrackTimer_Main_Module/02-tracktimer_server/elixir/tracktimer_2.0.3/_build/dev/lib/circuits_uart/obj/uart_enum_linux.o /home/antonie/Projects/TrackTimer_V2.0/02-TrackTimer_Main_Module/02-tracktimer_server/elixir/tracktimer_2.0.3/_build/dev/lib/circuits_uart/obj/uart_enum_osx.o /home/antonie/Projects/TrackTimer_V2.0/02-TrackTimer_Main_Module/02-tracktimer_server/elixir/tracktimer_2.0.3/_build/dev/lib/circuits_uart/obj/uart_enum_win.o /home/antonie/Projects/TrackTimer_V2.0/02-TrackTimer_Main_Module/02-tracktimer_server/elixir/tracktimer_2.0.3/_build/dev/lib/circuits_uart/obj/util.o -L/usr/lib64/erlang/usr/lib -lei -lrt -o /home/antonie/Projects/TrackTimer_V2.0/02-TrackTimer_Main_Module/02-tracktimer_server/elixir/tracktimer_2.0.3/_build/dev/lib/circuits_uart/priv/circuits_uart
/usr/bin/ld: /usr/libexec/gcc/x86_64-redhat-linux/13/liblto_plugin.so: error loading plugin: /usr/libexec/gcc/x86_64-redhat-linux/13/liblto_plugin.so: verkeerde ELF-klasse: ELFCLASS64
collect2: fout: ld gaf exit-status 1 terug
make: *** [src/Makefile:111: /home/antonie/Projects/TrackTimer_V2.0/02-TrackTimer_Main_Module/02-tracktimer_server/elixir/tracktimer_2.0.3/_build/dev/lib/circuits_uart/priv/circuits_uart] Fout 1
antonie3007 commented 1 year ago

@fhunleth

As far as I can see the CFLAGS and LDFLAGS are NOT defined in my environment echo $CFLAGS and echo $LDFLAGS give an empty response

Regards Antonie,

fhunleth commented 1 year ago

Hmm. My next guess is that this is coming from a compilation mismatch between the defaults (which Circuits.UART is getting) and whatever Erlang is compiled with.

The way to figure that out is by removing -L/usr/lib64/erlang/usr/lib -lei from the link step and trying it again:

cc /home/antonie/Projects/TrackTimer_V2.0/02-TrackTimer_Main_Module/02-tracktimer_server/elixir/tracktimer_2.0.3/_build/dev/lib/circuits_uart/obj/circuits_uart.o /home/antonie/Projects/TrackTimer_V2.0/02-TrackTimer_Main_Module/02-tracktimer_server/elixir/tracktimer_2.0.3/_build/dev/lib/circuits_uart/obj/debug_tests.o /home/antonie/Projects/TrackTimer_V2.0/02-TrackTimer_Main_Module/02-tracktimer_server/elixir/tracktimer_2.0.3/_build/dev/lib/circuits_uart/obj/erlcmd.o /home/antonie/Projects/TrackTimer_V2.0/02-TrackTimer_Main_Module/02-tracktimer_server/elixir/tracktimer_2.0.3/_build/dev/lib/circuits_uart/obj/uart_comm.o /home/antonie/Projects/TrackTimer_V2.0/02-TrackTimer_Main_Module/02-tracktimer_server/elixir/tracktimer_2.0.3/_build/dev/lib/circuits_uart/obj/uart_comm_unix.o /home/antonie/Projects/TrackTimer_V2.0/02-TrackTimer_Main_Module/02-tracktimer_server/elixir/tracktimer_2.0.3/_build/dev/lib/circuits_uart/obj/uart_comm_win.o /home/antonie/Projects/TrackTimer_V2.0/02-TrackTimer_Main_Module/02-tracktimer_server/elixir/tracktimer_2.0.3/_build/dev/lib/circuits_uart/obj/uart_enum.o /home/antonie/Projects/TrackTimer_V2.0/02-TrackTimer_Main_Module/02-tracktimer_server/elixir/tracktimer_2.0.3/_build/dev/lib/circuits_uart/obj/uart_enum_linux.o /home/antonie/Projects/TrackTimer_V2.0/02-TrackTimer_Main_Module/02-tracktimer_server/elixir/tracktimer_2.0.3/_build/dev/lib/circuits_uart/obj/uart_enum_osx.o /home/antonie/Projects/TrackTimer_V2.0/02-TrackTimer_Main_Module/02-tracktimer_server/elixir/tracktimer_2.0.3/_build/dev/lib/circuits_uart/obj/uart_enum_win.o /home/antonie/Projects/TrackTimer_V2.0/02-TrackTimer_Main_Module/02-tracktimer_server/elixir/tracktimer_2.0.3/_build/dev/lib/circuits_uart/obj/util.o -lrt -o /home/antonie/Projects/TrackTimer_V2.0/02-TrackTimer_Main_Module/02-tracktimer_server/elixir/tracktimer_2.0.3/_build/dev/lib/circuits_uart/priv/circuits_uart

You'll get errors about ei library functions not being found, but the ELFCLASS64 one should go away.

If this happens, then I'm not sure why. Maybe some google searches could lead you to some hints? I almost exclusively use asdf to install Erlang, so if that's an option, then I'd probably give that a try.

antonie3007 commented 1 year ago

Hmmmmm,

Retrying it with the command you send me stil get's me the error error loading plugin: /usr/libexec/gcc/x86_64-redhat-linux/13/liblto_plugin.so: wrong ELF-class: ELFCLASS64

I've tried installing Erlang and Elixir with asdf but I get the error:

checking whether the C compiler works... no
configure: error: in `/home/antonie/.asdf/plugins/erlang/kerl-home/builds/asdf_24.0/otp_src_24.0/erts':
configure: error: C compiler cannot create executables
See `config.log' for more details

and the config.log tells me:

Supported LTO compression algorithms: zlib zstd
gcc version 13.0.1 20230401 (Red Hat 13.0.1-0) (GCC) 
... rest of stderr output deleted ...
configure:4339: $? = 0
configure:4328: gcc -V >&5
gcc: error: unrecognized command-line option '-V'
gcc: fatal error: no input files
compilation terminated.
configure:4339: $? = 1
configure:4328: gcc -qversion >&5
gcc: error: unrecognized command-line option '-qversion'; did you mean '--version'?
gcc: fatal error: no input files
compilation terminated.
configure:4339: $? = 1
configure:4328: gcc -version >&5
gcc: error: unrecognized command-line option '-version'
gcc: fatal error: no input files
compilation terminated.
configure:4339: $? = 1
configure:4359: checking whether the C compiler works
configure:4381: gcc    conftest.c  >&5
/usr/bin/ld: /usr/libexec/gcc/x86_64-redhat-linux/13/liblto_plugin.so: error loading plugin: /usr/libexec/gcc/x86_64-redhat-linux/13/liblto_plugin.so: wrong ELF class: ELFCLASS64
collect2: error: ld returned 1 exit status
configure:4385: $? = 1
configure:4425: result: no

This seems like the same error of the liblto_plugin.so

Now I'am really lost...

regards Antonie

antonie3007 commented 1 year ago

Hi @fhunleth ,

Could this be an issue with Fedora 38 because it had an GNU Toolchain Update (gcc 13.0, binutils 2.39, glibc 2.37, gdb 12.1) in relation to the previous version of Fedora

asdf install of erlang and elixir and compile circuits.uart is working perfectly on Fedora 37

Gr. Antonie