odin-lang / Odin

Odin Programming Language
https://odin-lang.org
BSD 3-Clause "New" or "Revised" License
6.38k stars 561 forks source link

clang: error: unsupported option '-arch' for target 'x86_64-redhat-linux-gnu' #3461

Closed dufresnep closed 3 months ago

dufresnep commented 3 months ago

Context

make seems to produce debug version of odin, but just after that: paul@fedora:~/Odin$ make ./build_odin.sh debug

dufresnep commented 3 months ago

Also happens when trying to run hello.odin:

paul@fedora:~/myodin/hello$ ls
hello  hello.odin
paul@fedora:~/myodin/hello$ rm hello
paul@fedora:~/myodin/hello$ odin run .
clang: error: unsupported option '-arch' for target 'x86_64-redhat-linux-gnu'
paul@fedora:~/myodin/hello$ 
laytan commented 3 months ago

LLVM/clang 18 is not supported yet

dufresnep commented 3 months ago

I have tried on an other of my HD with Kubuntu. Previously this morning, was on 23.10, and was working fine.

Now after update to 24.04 Beta... I got:

paul@rafulos:~/Odin$ make
./build_odin.sh debug
+ clang++ src/main.cpp src/libtommath.cpp -Wno-switch -Wno-macro-redefined -Wno-unused-value -DODIN_VERSION_RAW="dev-2024-04" -DGIT_SHA="caa8863c9" -std=c++14 -I/usr/lib/llvm-17/include -std=c++17 -fno-exceptions -funwind-tables -D_GNU_SOURCE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -L/usr/lib/llvm-17/lib -g -pthread -lm -lstdc++ -ldl /usr/lib/llvm-17/lib/libLLVM-17.so -Wl,-rpath=$ORIGIN -o odin
+ set +x
clang: error: unsupported option '-arch' for target 'x86_64-pc-linux-gnu'
make: *** [Makefile:10: debug] Error 1
paul@rafulos:~/Odin$ odin report
Where to find more information and get into contact when you encounter a bug:

        Website: https://odin-lang.org
        GitHub:  https://github.com/odin-lang/Odin/issues

Useful information to add to a bug report:

        Odin:    dev-2024-04:caa8863c9
        OS:      Ubuntu Noble Numbat (development branch), Linux 6.8.0-31-generic
        CPU:     Intel(R) Core(TM) i3-8100 CPU @ 3.60GHz
        RAM:     15861 MiB
        Backend: LLVM 17.0.6
paul@rafulos:~/Odin$ clang --version
Ubuntu clang version 18.1.3 (1)
Target: x86_64-pc-linux-gnu
Thread model: posix
InstalledDir: /usr/bin
paul@rafulos:~/Odin$ 

I realize I need to test with an older version of clang.

dufresnep commented 3 months ago

Did:

sudo apt remove clang
git clean -dfx
paul@rafulos:~/Odin$ CC=clang++-17 make
./build_odin.sh debug
+ clang++ src/main.cpp src/libtommath.cpp -Wno-switch -Wno-macro-redefined -Wno-unused-value -DODIN_VERSION_RAW="dev-2024-04" -DGIT_SHA="caa8863c9" -std=c++14 -I/usr/lib/llvm-17/include -std=c++17 -fno-exceptions -funwind-tables -D_GNU_SOURCE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -L/usr/lib/llvm-17/lib -g -pthread -lm -lstdc++ -ldl /usr/lib/llvm-17/lib/libLLVM-17.so -Wl,-rpath=$ORIGIN -o odin
./build_odin.sh: 121: clang++: not found
make: *** [Makefile:10: debug] Error 127
paul@rafulos:~/Odin$ whereis clang++-17
clang++-17: /usr/bin/clang++-17
paul@rafulos:~/Odin$ 

Is there an easy web to force the use of clang++-17 ?

dufresnep commented 3 months ago
paul@rafulos:~/Odin$ git diff build_odin.sh
diff --git a/build_odin.sh b/build_odin.sh
index c53766290..f02c4242c 100755
--- a/build_odin.sh
+++ b/build_odin.sh
@@ -2,7 +2,7 @@
 set -eu

 : ${CPPFLAGS=}
-: ${CXX=clang++}
+: ${CXX=clang++-17}
 : ${CXXFLAGS=}
 : ${LDFLAGS=}
 : ${LLVM_CONFIG=}
paul@rafulos:~/Odin$ 

paul@rafulos:~/Odin$ make 
./build_odin.sh debug
+ clang++-17 src/main.cpp src/libtommath.cpp -Wno-switch -Wno-macro-redefined -Wno-unused-value -DODIN_VERSION_RAW="dev-2024-04" -DGIT_SHA="caa8863c9" -std=c++14 -I/usr/lib/llvm-17/include -std=c++17 -fno-exceptions -funwind-tables -D_GNU_SOURCE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -L/usr/lib/llvm-17/lib -g -pthread -lm -lstdc++ -ldl /usr/lib/llvm-17/lib/libLLVM-17.so -Wl,-rpath=$ORIGIN -o odin
+ set +x
sh: 1: clang: not found
make: *** [Makefile:10: debug] Error 127
dufresnep commented 3 months ago

With:

paul@rafulos:~/Odin$ file /usr/bin/clang
/usr/bin/clang: symbolic link to /usr/lib/llvm-17/bin/clang
paul@rafulos:~/Odin$ odin report
Where to find more information and get into contact when you encounter a bug:

        Website: https://odin-lang.org
        GitHub:  https://github.com/odin-lang/Odin/issues

Useful information to add to a bug report:

        Odin:    dev-2024-04:caa8863c9
        OS:      Ubuntu Noble Numbat (development branch), Linux 6.8.0-31-generic
        CPU:     Intel(R) Core(TM) i3-8100 CPU @ 3.60GHz
        RAM:     15861 MiB
        Backend: LLVM 17.0.6
paul@rafulos:~/Odin$ 

that works! So it really seems to be linked to the use of clang version 18.

dufresnep commented 3 months ago

I have been able to make Fedora 40 works with odin by:

git clean -fdx
paul@fedora:~/Odin$ git diff build_odin.sh
diff --git a/build_odin.sh b/build_odin.sh
index c53766290..43eba9797 100755
--- a/build_odin.sh
+++ b/build_odin.sh
@@ -2,10 +2,10 @@
 set -eu

 : ${CPPFLAGS=}
-: ${CXX=clang++}
+: ${CXX=clang++-17}
 : ${CXXFLAGS=}
 : ${LDFLAGS=}
-: ${LLVM_CONFIG=}
+: ${LLVM_CONFIG=/usr/lib64/llvm17/bin/llvm-config}

 CPPFLAGS="$CPPFLAGS -DODIN_VERSION_RAW=\"dev-$(date +"%Y-%m")\""
 CXXFLAGS="$CXXFLAGS -std=c++14"
paul@fedora:~/Odin$ ln -s /usr/lib64/llvm17/bin/clang  ~/.local/bin/clang
then make

odin then report "badly" version 18.1.1