Koheron / koheron-sdk

SDK for FPGA / Linux Instruments
https://www.koheron.com/software-development-kit/
Other
101 stars 41 forks source link

/usr/bin/arm-linux-gnueabihf-g++-8 complier error #542

Open 13121186 opened 3 years ago

13121186 commented 3 years ago

When I use: /usr/bin/arm-linux-gnueabihf-g++-8 I got this compilation error: cc1plus: error: switch -mcpu=cortex-a9 conflicts with -march=armv7-a switch [-Werror]

I had no such issue when I used /usr/bin/arm-linux-gnueabihf-g++-5

How to fix it? Thanks.

tvanderbruggen commented 3 years ago

This might be specific to gcc-8 (I just rebuilt u-boot and the kernel with gcc-9 without error).

Anyway, defining both march and mcpu doesn't make much sense (see https://gcc.gnu.org/bugzilla/show_bug.cgi?id=72736 for a related issue).

It would make sense to use the same flags that to compile the server. Can you try PR #543 and see whether this fixes the error ?

13121186 commented 3 years ago

How to update the CFLAGS? Can you provide the command? This issue also exists in g++-9 and g++10 in Ubuntu 20.04. In g++-5, there is no such issue. It(defining both march and mcpu) is successful to compile koheron SDK code. It seems in Ubuntu 16.04. I don't know if the Ubuntu version matters or not. In Ubuntu 20.04, trying to install g++-5, it said the package cannot be found. Thanks.

13121186 commented 3 years ago

I mean what CFLAGS you suggest to update? mcpu, march, or else? Thanks.

tvanderbruggen commented 3 years ago

Can you perform the following change in os/os.mk:

https://github.com/Koheron/koheron-sdk/pull/543/files

Also I just compiled it on Ubuntu 20.04 with g++-9 and I don't have your error. Can you post a log of the error ?

13121186 commented 3 years ago
  1. g++-9 /usr/bin/arm-linux-gnueabihf-g++-9 -flto -c -Wall -Werror -Wextra -Wpedantic -Wfloat-equal -Wunused-macros -Wcast-qual -Wuseless-cast -Wlogical-op -Wdouble-promotion -Wformat -Wmissing-include-dirs -Wundef -Wcast-align -Wpacked -Wredundant-decls -Wvarargs -Wvector-operation-performance -Wswitch-default -Wuninitialized -Wshadow -Wzero-as-null-pointer-constant -Wmissing-declarations -Itmp/examples/alpha250/fft//server -I./server/core -I. -I. -I./server/context -I./server/drivers -Iexamples/alpha250/fft/ -DKOHERON_VERSION=0.21.0.8237ed1 -MMD -MP -O3 -march=armv7-a -mcpu=cortex-a9 -mfpu=vfpv3-d16 -mvectorize-with-neon-quad -mfloat-abi=hard -std=c++14 -pthread -o tmp/examples/alpha250/fft//server/sha1.o server/core/sha1.cpp cc1plus: error: switch ‘-mcpu=cortex-a9’ conflicts with ‘-march=armv7-a’ switch [-Werror]

also, another error showed up: inlined from ‘koheron::Server::notify_systemd_ready()’ at server/core/server.cpp:127:12: /usr/arm-linux-gnueabihf/include/bits/string_fortified.h:106:34: error: ‘strncpy’ output truncated before terminating nul copying 19 bytes from a string of the same length [-Werror=stringop-truncation] 106 | return builtin___strncpy_chk (dest, src, len, bos (dest)); | ~~~~~~^~~~~~~~

  1. g++-10 /usr/bin/arm-linux-gnueabihf-g++-10 -flto -c -Wall -Werror -Wextra -Wpedantic -Wfloat-equal -Wunused-macros -Wcast-qual -Wuseless-cast -Wlogical-op -Wdouble-promotion -Wformat -Wmissing-include-dirs -Wundef -Wcast-align -Wpacked -Wredundant-decls -Wvarargs -Wvector-operation-performance -Wswitch-default -Wuninitialized -Wshadow -Wzero-as-null-pointer-constant -Wmissing-declarations -Itmp/examples/alpha250/fft//server -I./server/core -I. -I. -I./server/context -I./server/drivers -Iexamples/alpha250/fft/ -DKOHERON_VERSION=0.21.0.8237ed1 -MMD -MP -O3 -march=armv7-a -mcpu=cortex-a9 -mfpu=vfpv3-d16 -mvectorize-with-neon-quad -mfloat-abi=hard -std=c++14 -pthread -o tmp/examples/alpha250/fft//server/sha1.o server/core/sha1.cpp cc1plus: error: switch ‘-mcpu=cortex-a9’ conflicts with ‘-march=armv7-a’ switch [-Werror]

also, another error showed up: inlined from ‘koheron::Server::notify_systemd_ready()’ at server/core/server.cpp:127:12: /usr/arm-linux-gnueabihf/include/bits/string_fortified.h:106:34: error: ‘strncpy’ output truncated before terminating nul copying 19 bytes from a string of the same length [-Werror=stringop-truncation] 106 | return builtin___strncpy_chk (dest, src, len, bos (dest)); | ~~~~~~^~~~~~~~

tvanderbruggen commented 3 years ago

Your compile flags are not up to date, you need to use the last release of the SDK to build with GCC >= 7 (https://github.com/Koheron/koheron-sdk/commit/7bfddcae9c2b672f8911a71297888aa22dd1af16).

13121186 commented 3 years ago

with your above suggestions, now I can compile the files without errors. However, browser brings out nothing, blank web page When I use Ubuntu16.06 with g++-5, the FFT plot is successfully showing up on the browser. Any further advices on this? Thanks.

tvanderbruggen commented 3 years ago

Did you update the SD card image ? You can find the latest one here (https://www.koheron.com/software-development-kit/documentation/ubuntu-zynq/)

13121186 commented 3 years ago

What is the SD card image updating procedure? I am not the first user on my alpha250 board and I don't want to break anything on that. --Is a USB-SD adapter needed? --Any special utility to do this upgrade? Or just download your file and unzip it, then copy to the SD card? --Should I format the SD card first before upgrading? --Should I back up the existing SD image first? Thanks.

tvanderbruggen commented 3 years ago
13121186 commented 3 years ago

I was able to upload V.22 OS to the Alph250 board, compilation successful but failed to load the web page.

journalctl -u koheron-server -n 300 shows the log info and these errors found as following:

]: /tmp/live-instrument/serverd: /lib/arm-linux-gnueabihf/libm.so.6: version GLIBC_2.29' not found (required by /tmp/live-instrument/serverd) Feb 12 16:37:13 koheron serverd[3179]: /tmp/live-instrument/serverd: /usr/lib/arm-linux-gnueabihf/libstdc++.so.6: versionGLIBCXX_3.4.22' not found (required by /tmp/live-instrument/serverd) Feb 12 16:37:13 koheron systemd[1]: koheron-server.service: Main process exited, code=exited, status=1/FAILURE Feb 12 16:37:13 koheron systemd[1]: koheron-server.service: Control process exited, code=exited status=1 Feb 12 16:37:13 koheron systemd[1]: Failed to start Koheron TCP/Websocket server. Feb 12 16:37:13 koheron systemd[1]: koheron-server.service: Unit entered failed state. Feb 12 16:37:13 koheron systemd[1]: koheron-server.service: Failed with result 'exit-code'.

tvanderbruggen commented 3 years ago

This happen because the version of glibc used to compile the server is not the same as the one installed on the OS. To avoid this, we are now statistically linking the library with the executable (that's the -static-libstdc++ flag).

Could you make sure you cleaned eveything before building and show the compilation log to check the flags ?

13121186 commented 3 years ago

I did clean build and the flag static-libstdc++ is there, but still see the same error. Here is my compilation log: /usr/bin/arm-linux-gnueabihf-g++-9 -flto -c -Wall -Werror -Wextra -Wpedantic -Wfloat-equal -Wunused-macros -Wcast-qual -Wuseless-cast -Wlogical-op -Wdouble-promotion -Wformat -Wmissing-include-dirs -Wundef -Wcast-align -Wpacked -Wredundant-decls -Wvarargs -Wvector-operation-performance -Wswitch-default -Wuninitialized -Wshadow -Wzero-as-null-pointer-constant -Wmissing-declarations -Itmp/examples/alpha250/fft//server -I./server/core -I. -I. -I./server/context -I./server/drivers -Iexamples/alpha250/fft/ -DKOHERON_VERSION=0.22.1.8237ed1 -MMD -MP -O3 -mcpu=cortex-a9 -mfpu=vfpv3-d16 -mvectorize-with-neon-quad -mfloat-abi=hard -std=c++17 -pthread -lstdc++ -lstdc++fs -static-libstdc++ -o tmp/examples/alpha250/fft//server/i2c_dev.o server/context/i2c_dev.cpp

13121186 commented 3 years ago

actually only this issue now: "GLIBC_2.29' not found". The other issue: "GLIBCXX_3.4.22' not found" is gone.

Feb 15 09:20:34 koheron serverd[7881]: /tmp/live-instrument/serverd: /lib/arm-linux-gnueabihf/libm.so.6: version `GLIBC_2.29' not found (required by /tm Feb 15 09:20:34 koheron systemd[1]: koheron-server.service: Main process exited, code=exited, status=1/FAILURE Feb 15 09:20:34 koheron systemd[1]: koheron-server.service: Control process exited, code=exited status=1 Feb 15 09:20:34 koheron systemd[1]: Failed to start Koheron TCP/Websocket server. Feb 15 09:20:34 koheron systemd[1]: koheron-server.service: Unit entered failed state. Feb 15 09:20:34 koheron systemd[1]: koheron-server.service: Failed with result 'exit-code'.

13121186 commented 3 years ago

Another clue, from the browser, when I tried to type ##.##.##.##(my Alpha250 IP address), I got error and stuck showing nothing: app.js:68 WebSocket connection to 'ws://##.##.##.##:8080/' failed: Suppose I should see the PSD plot as it showed before the OS SD image update.

tvanderbruggen commented 3 years ago

The fact that the issue "GLIBCXX_3.4.22' not found" is gone means that libstdc++ has been statically linked. For for some reason there is some issue with GLIBC.

Which version of Ubuntu are using for building ? (Can you run cat /etc/os-release)

Also, can you show the result of strings /lib32/libm.so.6 | grep GLIBC on your building machine.

NB: The Websocket connection error is expected because the websocket server (/tmp/live-instrument/serverd) is not started.

13121186 commented 3 years ago

Thanks. ==Check Ubuntu version: Running: cat /etc/os-release

  1. Inside Alpha250 Welcome to Ubuntu 16.04.7 LTS (GNU/Linux 4.9.0-xilinx armv7l)

2.inside WSL distro (Ubuntu-20.04)

cat /etc/os-release NAME="Ubuntu" VERSION="20.04.1 LTS (Focal Fossa)" ID=ubuntu ID_LIKE=debian PRETTY_NAME="Ubuntu 20.04.1 LTS" VERSION_ID="20.04" HOME_URL="https://www.ubuntu.com/" SUPPORT_URL="https://help.ubuntu.com/" BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/" PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy" VERSION_CODENAME=focal UBUNTU_CODENAME=focal

==check GLIBC strings /lib32/libm.so.6 | grep GLIBC GLIBC_2.0 GLIBC_2.1 GLIBC_2.2 GLIBC_2.4 GLIBC_2.15 GLIBC_2.18 GLIBC_2.23 GLIBC_2.24 GLIBC_2.25 GLIBC_2.26 GLIBC_2.27 GLIBC_2.28 GLIBC_2.29 GLIBC_2.31 GLIBC_PRIVATE GLIBC_2.1.3

13121186 commented 3 years ago

When I check GLIBC in the Alpha250 board, strings /lib32/libm.so.6 | grep GLIBC strings: '/lib32/libm.so.6': No such file I see this: 12 Jun 8 2020 libm.so.6 -> libm-2.23.so

In Alpha250, OS V.22 still Ubuntun 16.04. Can you upgrade your OS image to Ubuntun 20.04? Will it help? Thanks.

tvanderbruggen commented 3 years ago

Your build os seems the same as us, but I see you are using WSL and we haven't tested it (we have tested on native ubuntu machines, and VirtualBox VMs).

I still find weird that only one error disappears once you cleaned ...

tvanderbruggen commented 3 years ago

Could you try to setup a Virtual VM (https://www.koheron.com/software-development-kit/documentation/setup-development-machine/) to see whether there is still the issue ?

13121186 commented 3 years ago

I think the OS image in the Alpha250 board should be upgraded to ubuntu 20.04 as well to match the WSL ubuntu20.04 where I build the Koheron image. I tried downgrading my WSL ubuntu 20.04 to ubuntu 16.04 which matches the version in the Alpha250 board. Now it is working without issues.

13121186 commented 3 years ago

Do you plan to support Ubuntu 20.04 in case Ubuntu16.04 will be obsoleted some time near future? Thanks.

tvanderbruggen commented 3 years ago

Yes, we do plan to support Ubuntu 20.4. There is some first work being done (https://github.com/Koheron/koheron-sdk/pull/544) but it's still in progress ...

13121186 commented 3 years ago

Thanks a lot!

nbhebert commented 2 years ago

I am having a similar problem, although I am not using WSL to build instruments. I am running a native Ubuntu22.04 machine where I installed gnueabihf-g++-9 as chosen by default in the makefile. Do I understand correctly that the solution is to build instruments using Ubuntu16.04 for now? Some more info on my particular situation below, including error logs. Thank you!

  1. One of the errors in the instrument compilation log is:

/usr/bin/arm-linux-gnueabihf-g++-9 -flto -c -Wall -Werror -Wextra -Wpedantic -Wfloat-equal -Wunused-macros -Wcast-qual -Wuseless-cast -Wlogical-op -Wdouble-promotion -Wformat -Wmissing-include-dirs -Wundef -Wcast-align -Wpacked -Wredundant-decls -Wvarargs -Wvector-operation-performance -Wswitch-default -Wuninitialized -Wshadow -Wzero-as-null-pointer-constant -Wmissing-declarations -Itmp/examples/alpha250/adc-dac-bram//server -I./server/core -I. -I. -I./server/context -I./server/drivers -Iexamples/alpha250/adc-dac-bram/ -DKOHERON_VERSION=0.22.2.e3a9f77 -MMD -MP -O3 -mcpu=cortex-a9 -mfpu=vfpv3-d16 -mvectorize-with-neon-quad -mfloat-abi=hard -std=c++17 -pthread -lstdc++ -lstdc++fs -static-libstdc++ -o tmp/examples/alpha250/adc-dac-bram//server/i2c_dev.o server/context/i2c_dev.cpp

  1. The instrument still compiles and after uploading it to the Alpha250, the koheron-server throws these errors:

Feb 11 17:03:13 koheron serverd[1861]: /tmp/live-instrument/serverd: /lib/arm-linux-gnueabihf/libc.so.6: version GLIBC_2.33' not found (required by /tmp/live-instrument/serverd) Feb 11 17:03:13 koheron serverd[1861]: /tmp/live-instrument/serverd: /lib/arm-linux-gnueabihf/libc.so.6: versionGLIBC_2.34' not found (required by /tmp/live-instrument/serverd)

  1. Info on my OS and GLIBC :

cat /etc/os-release PRETTY_NAME="Ubuntu 22.04 LTS" NAME="Ubuntu" VERSION_ID="22.04" VERSION="22.04 (Jammy Jellyfish)" VERSION_CODENAME=jammy ID=ubuntu ID_LIKE=debian HOME_URL="https://www.ubuntu.com/" SUPPORT_URL="https://help.ubuntu.com/" BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/" PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy" UBUNTU_CODENAME=jammy

strings /lib32/libm.so.6 | grep GLIBC GLIBC_2.0 GLIBC_2.1 GLIBC_2.2 GLIBC_2.4 GLIBC_2.15 GLIBC_2.18 GLIBC_2.23 GLIBC_2.24 GLIBC_2.25 GLIBC_2.26 GLIBC_2.27 GLIBC_2.28 GLIBC_2.29 GLIBC_2.31 GLIBC_2.32 GLIBC_2.35 GLIBC_PRIVATE GLIBC_2.1.3

nbhebert commented 2 years ago

Just an update that after reverting to using Ubuntu 20.04 to build instruments (as suggested here https://www.koheron.com/software-development-kit/documentation/setup-development-machine ) everything works fine.