odin-lang / Odin

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

Prebuilt odin won't run on MacOS 10.13.6 #4095

Closed oDr0zd closed 3 weeks ago

oDr0zd commented 3 weeks ago

I downloaded the latest version of Odin (I'm using macos 10.13.6) but when I type ./odin version i get

dyld: cannot load 'odin' (load command 0x80000034 is unknown)
Abort trap: 6

Does mac os 10.13 support latest odin? I also tried building from source but ended up with a bunch of errors related to SSE instructions. Any ideas?

Kelimion commented 3 weeks ago

What version of LLVM is installed via homebrew?

And please post the compile errors. It's hard to go off "a bunch of errors".

laytan commented 3 weeks ago

What version of LLVM is installed via homebrew?

That's actually not required anymore with the prebuilt releases.

I do think however that MacOS 10.13 is not going to be supported at the moment, that's quite old.

Kelimion commented 3 weeks ago

What version of LLVM is installed via homebrew?

That's actually not required anymore with the prebuilt releases.

I do think however that MacOS 10.13 is not going to be supported at the moment, that's quite old.

I was thinking "I also tried building from source" when I asked that.

oDr0zd commented 3 weeks ago

Ok so here's what I get trying to build from source. I'm using llvm 14.

PROGRAM=make ./build_odin.sh # debug
+ clang++ src/main.cpp src/libtommath.cpp -Wno-switch -Wno-macro-redefined -Wno-unused-value -mno-sse -mno-sse2 -mno-avx -mno-avx2 '-DODIN_VERSION_RAW="dev-2024-08"' '-DGIT_SHA="478f52974"' -std=c++14 -I/opt/local/libexec/llvm-14/include -std=c++14 -stdlib=libc++ -fno-exceptions -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -L/opt/local/libexec/llvm-14/lib -Wl,-search_paths_first -Wl,-headerpad_max_install_names --sysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk -g -pthread -lm -lstdc++ -liconv -ldl -framework System -lLLVM -o odin
src/main.cpp:1882:21: error: SSE register return with SSE disabled
                        f64 parse_time = time_stamp_as_s(ts, t->freq);
                                         ^
src/main.cpp:1912:21: error: SSE register return with SSE disabled
                        f64 parse_time = time_stamp_as_s(ts, t->freq);
                                         ^
In file included from src/main.cpp:9:
src/big_int.cpp:579:26: error: SSE register return with SSE disabled
                double mant = 1.0e-3 * mp_get_double(&thousand_above);
                                       ^
In file included from src/main.cpp:13:
src/exact_value.cpp:345:10: error: SSE register return with SSE disabled
        f64 f = float_from_string(string, &success);
                ^
src/exact_value.cpp:325:12: error: SSE register return with SSE disabled
                        f32 f = f16_to_f32(x);
                                ^
In file included from src/main.cpp:2:
src/common.cpp:638:2: error: SSE register return with SSE disabled
        return v.f;
        ^
In file included from src/main.cpp:13:
src/exact_value.cpp:228:11: error: SSE register return with SSE disabled
                f64 f = strtod(buf, &end_ptr);
                        ^
src/exact_value.cpp:208:11: error: SSE register return with SSE disabled
                f64 f = strtod(buf, &end_ptr);
                        ^
src/exact_value.cpp:311:1: error: SSE register return with SSE disabled
}
^
src/exact_value.cpp:362:14: error: SSE register return with SSE disabled
                f64 imag = float_from_string(str);
                           ^
fatal error: error in backend: SSE register return with SSE disabled
In file included from src/libtommath.cpp:35:
src/libtommath/mp_get_double.c:16:4: error: SSE register return with SSE disabled
   return mp_isneg(a) ? -d : d;
   ^
1 error generated.
clang: error: clang frontend command failed with exit code 70 (use -v to see invocation)
Apple LLVM version 10.0.0 (clang-1000.11.45.5)
Target: x86_64-apple-darwin17.7.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin
clang: note: diagnostic msg: PLEASE submit a bug report to http://developer.apple.com/bugreporter/ and include the crash backtrace, preprocessed source, and associated run script.
clang: note: diagnostic msg: 
********************

PLEASE ATTACH THE FOLLOWING FILES TO THE BUG REPORT:
Preprocessed source(s) and associated run script(s) are located at:
clang: note: diagnostic msg: /var/folders/6n/x52p31j50dz9w0vnd3f4hmwh0000gn/T/main-1d4fd1.cpp
clang: note: diagnostic msg: /var/folders/6n/x52p31j50dz9w0vnd3f4hmwh0000gn/T/libtommath-6ac3e9.cpp
clang: note: diagnostic msg: /var/folders/6n/x52p31j50dz9w0vnd3f4hmwh0000gn/T/main-1d4fd1.sh
clang: note: diagnostic msg: Crash backtrace is located in
clang: note: diagnostic msg: /Users/admin/Library/Logs/DiagnosticReports/clang_<YYYY-MM-DD-HHMMSS>_<hostname>.crash
clang: note: diagnostic msg: (choose the .crash file that corresponds to your crash)
clang: note: diagnostic msg: 

********************
make: *** [default] Error 70
oDr0zd commented 3 weeks ago

I guess @laytan is right about too old macos version... Or probably there is still a way? I can install odin via macports thoug, but the version I can install this way is dev-2024-07. The problem is it's too old for OLS vscode extention :)

Kelimion commented 3 weeks ago

Looks like LLVM 10, not 14. I don't recall when it was last supported, but the lowest supported version is LLVM 11.

clang: error: clang frontend command failed with exit code 70 (use -v to see invocation)
Apple LLVM version 10.0.0 (clang-1000.11.45.5)
Target: x86_64-apple-darwin17.7.0
Thread model: posix

You could try updating LLVM and seeing if that helps.

oDr0zd commented 3 weeks ago

Well I have this in my .bash_profile

# adding llvm to PATH
export PATH="/opt/local/bin:$PATH"
export LLVM_CONFIG=/opt/local/bin/llvm-config-mp-14
export DYLD_LIBRARY_PATH=/opt/local/libexec/llvm-14/lib/libLLVM.dylib

By the way llvm is installed via macports as well, not via homebrew. But it still uses llvm 10?

laytan commented 3 weeks ago

LLVM<= 13 doesn't work, see https://github.com/odin-lang/Odin/issues/4017

oDr0zd commented 3 weeks ago

But I have LLVM 14 installed and added to my path. I wonder why does it use version 10, like, by default.. probably because it installed with XCode 10.1 which is last version supported on macos 10.13.6.

laytan commented 3 weeks ago

You can do LLVM_CONFIG=llvm-config-14 make to overwrite the llvm version/path

oDr0zd commented 3 weeks ago

if i do LLVM_CONFIG=llvm-config-14 make it gives me command not found error:

Admins-Mac-mini:Odin admin$ LLVM_CONFIG=llvm-config-14 make
PROGRAM=make ./build_odin.sh # debug
./build_odin.sh: line 56: llvm-config-14: command not found
make: *** [default] Error 127

I can do LLVM_CONFIG=llvm-config-mp-14 make

and as I can see it gives me the same error:

Admins-Mac-mini:Odin admin$ LLVM_CONFIG=llvm-config-mp-14 make
PROGRAM=make ./build_odin.sh # debug
+ clang++ src/main.cpp src/libtommath.cpp -Wno-switch -Wno-macro-redefined -Wno-unused-value -mno-sse -mno-sse2 -mno-avx -mno-avx2 '-DODIN_VERSION_RAW="dev-2024-08"' '-DGIT_SHA="478f52974"' -std=c++14 -I/opt/local/libexec/llvm-14/include -std=c++14 -stdlib=libc++ -fno-exceptions -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -L/opt/local/libexec/llvm-14/lib -Wl,-search_paths_first -Wl,-headerpad_max_install_names --sysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk -g -pthread -lm -lstdc++ -liconv -ldl -framework System -lLLVM -o odin
src/main.cpp:1882:21: error: SSE register return with SSE disabled
                        f64 parse_time = time_stamp_as_s(ts, t->freq);
                                         ^
src/main.cpp:1912:21: error: SSE register return with SSE disabled
                        f64 parse_time = time_stamp_as_s(ts, t->freq);
                                         ^
In file included from src/main.cpp:9:
src/big_int.cpp:579:26: error: SSE register return with SSE disabled
                double mant = 1.0e-3 * mp_get_double(&thousand_above);
                                       ^
In file included from src/main.cpp:13:
src/exact_value.cpp:345:10: error: SSE register return with SSE disabled
        f64 f = float_from_string(string, &success);
                ^
src/exact_value.cpp:325:12: error: SSE register return with SSE disabled
                        f32 f = f16_to_f32(x);
                                ^
In file included from src/main.cpp:2:
src/common.cpp:638:2: error: SSE register return with SSE disabled
        return v.f;
        ^
In file included from src/main.cpp:13:
src/exact_value.cpp:228:11: error: SSE register return with SSE disabled
                f64 f = strtod(buf, &end_ptr);
                        ^
src/exact_value.cpp:208:11: error: SSE register return with SSE disabled
                f64 f = strtod(buf, &end_ptr);
                        ^
src/exact_value.cpp:311:1: error: SSE register return with SSE disabled
}
^
src/exact_value.cpp:362:14: error: SSE register return with SSE disabled
                f64 imag = float_from_string(str);
                           ^
fatal error: error in backend: SSE register return with SSE disabled
In file included from src/libtommath.cpp:35:
src/libtommath/mp_get_double.c:16:4: error: SSE register return with SSE disabled
   return mp_isneg(a) ? -d : d;
   ^
1 error generated.
clang: error: clang frontend command failed with exit code 70 (use -v to see invocation)
Apple LLVM version 10.0.0 (clang-1000.11.45.5)
Target: x86_64-apple-darwin17.7.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin
clang: note: diagnostic msg: PLEASE submit a bug report to http://developer.apple.com/bugreporter/ and include the crash backtrace, preprocessed source, and associated run script.
clang: note: diagnostic msg: 
********************

PLEASE ATTACH THE FOLLOWING FILES TO THE BUG REPORT:
Preprocessed source(s) and associated run script(s) are located at:
clang: note: diagnostic msg: /var/folders/6n/x52p31j50dz9w0vnd3f4hmwh0000gn/T/main-8e7c66.cpp
clang: note: diagnostic msg: /var/folders/6n/x52p31j50dz9w0vnd3f4hmwh0000gn/T/libtommath-a6b126.cpp
clang: note: diagnostic msg: /var/folders/6n/x52p31j50dz9w0vnd3f4hmwh0000gn/T/main-8e7c66.sh
clang: note: diagnostic msg: Crash backtrace is located in
clang: note: diagnostic msg: /Users/admin/Library/Logs/DiagnosticReports/clang_<YYYY-MM-DD-HHMMSS>_<hostname>.crash
clang: note: diagnostic msg: (choose the .crash file that corresponds to your crash)
clang: note: diagnostic msg: 

********************
make: *** [default] Error 70
oDr0zd commented 3 weeks ago

I'm sorry, I do ML and web dev most of the time with Python/JS, never really did any serious stuff with C/C++/CMake, sorry for annoying questions haha.. know some basics of those only

patrickrealdeal commented 3 weeks ago

I installed LLVM 14 with brew and some hacks in debug mode on 10.13 and it works until dev-07, with the latest version I get an error with src/threading.cpp

./build_odin.sh release

./build_odin.sh: line 146: 1204 Illegal instruction: 4 ./odin run examples/demo -vet -strict-style -- Hellope World make: *** [release] Error 132

laytan commented 3 weeks ago

Ah, I am guessing the flag we added here https://github.com/odin-lang/Odin/commit/03426175aea8b3d3a1ebea550613f2155ea07f9a is not implemented on old macOS. Unfortunately it isn't documented/public from Apple so would be hard to figure out when it is available.

patrickrealdeal commented 3 weeks ago

Changing the else branches back to UL_COMPARE_AND_WAIT fixes the issue locally, I can use latest version now thanks!

patrickrealdeal commented 3 weeks ago

I downloaded the latest version of Odin (I'm using macos 10.13.6) but when I type ./odin version i get

dyld: cannot load 'odin' (load command 0x80000034 is unknown)
Abort trap: 6

Does mac os 10.13 support latest odin? I also tried building from source but ended up with a bunch of errors related to SSE instructions. Any ideas?

Follow this to install llvm 14 and use it as default on your system, you should be able to build dev-07 from source after you do this https://gist.github.com/amekusa/59758c85ecaf7119f5cd96a5df191d3b

laytan commented 3 weeks ago

Ok found out somewhere that UL_COMPARE_AND_WAIT_SHARED is macOS 10.15+, I will add a path for versions below that.

laytan commented 3 weeks ago

I am going to close this as I don't think there's anything else to do here. At least you can build from source now.

JustForCodin commented 3 weeks ago

Ok now I can build from source! Thank you so much ;)