Closed Lidbetter closed 2 years ago
I don't think you can compile for 32 bit binaries in general on macOS anymore. It's 64bit only since a few versions. You need an older macos or xcode version, but I don't use macs, so can't tell you the details.
I also want to be able to build SourceMod on WSL1 that supports executing binaries in x86_64 mode, which leads to the same problem
wend4r@Wend4rPC:/mnt/d/C++/alliedmodders/sourcemod/build/linux_all$ ./initialize_release.sh
Checking CC compiler (vendor test gcc)... ['clang', '-m32', 'test.c', '-o', 'test-c']
Compiler clang for CC failed: failed to create executable with clang
Checking CC compiler (vendor test gcc)... ['gcc', '-m32', 'test.c', '-o', 'test-c']
Compiler gcc for CC failed: failed to create executable with gcc
Checking CC compiler (vendor test gcc)... ['icc', '-m32', 'test.c', '-o', 'test-c']
Compiler icc for CC failed: [Errno 2] No such file or directory: 'icc'
Skipping target x86: Unable to find a suitable C/C++ compiler
Traceback (most recent call last):
File "/home/wend4r/.local/lib/python3.9/site-packages/ambuild2/frontend/v2_2/prep.py", line 137, in Configure
if not cm.generate(options.generator):
File "/home/wend4r/.local/lib/python3.9/site-packages/ambuild2/frontend/context_manager.py", line 93, in generate
self.parseBuildScripts()
File "/home/wend4r/.local/lib/python3.9/site-packages/ambuild2/frontend/v2_2/context_manager.py", line 50, in parseBuildScripts
self.execContext(cx)
File "/home/wend4r/.local/lib/python3.9/site-packages/ambuild2/frontend/v2_2/context_manager.py", line 148, in execContext
exec(code, scriptGlobals)
File "/mnt/d/C++/alliedmodders/sourcemod/AMBuildScript", line 738, in <module>
SM = SMConfig()
File "/mnt/d/C++/alliedmodders/sourcemod/AMBuildScript", line 148, in __init__
raise Exception('No suitable C/C++ compiler was found.')
Exception: No suitable C/C++ compiler was found.
Configure failed: No suitable C/C++ compiler was found.
wend4r@Wend4rPC:/mnt/d/C++/alliedmodders/sourcemod/build/linux_all$ cd .ambuild2
wend4r@Wend4rPC:/mnt/d/C++/alliedmodders/sourcemod/build/linux_all/.ambuild2$ ls
graph test.c test.cpp test-cxx vars
wend4r@Wend4rPC:/mnt/d/C++/alliedmodders/sourcemod/build/linux_all/.ambuild2$ clang -m32 test.c -o test-c
wend4r@Wend4rPC:/mnt/d/C++/alliedmodders/sourcemod/build/linux_all/.ambuild2$ ./test-c
-bash: ./test-c: cannot execute binary file: Exec format error
I have done some more digging. By installing xcode 9.4.1 (https://developer.apple.com/download/all/?q=Xcode%209.4.1) and running this to fixup things to make it work on Monterey: https://github.com/mrpippy/XcodeNueve
This succeeds:
DEVELOPER_DIR=/Applications/Xcode9.app SDKROOT=/Applications/Xcode9.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.13.sdk clang -m32 .ambuild2/test.c -o test-c
I'm having trouble figuring out how to modify ambuild to setup env in the context of clang / gcc execution
We only support macOS <= 10.14. It is still possible to build on newer versions, but it's most likely a lot of work. If you can get it to work on later versions, that's great, and feel free to update the wiki with instructions.
The problem with WSL1 (and assumedly macOS 10.15+) is that they don't support executing 32-bit code. AMBuild currently expects that an x86_64 OS can execute x86 code. But, we can build exceptions for this for WSL1 and macOS if you'd like. Please file an AMBuild bug and I'll fix it in the next few weeks.
Note, if you weren't aware, WSL2 is a true VM whereas WSL1 is emulated. I'd recommend using WSL2.
It would be nice to get things working on newer osx versions, but I think given the hoops I had to jump through already + modifications needed to the build process, it's probably not worth it.
Compiling on linux in a vm or docker would probably be a better time investment.
Thanks for feedback regarding macos - I have updated the wiki to include info about 10.14
being a maximum supported version
Help us help you
Environment
7d6eb2bd81323e6c191dacf3b34781b53dc495a0
Description
Following the instructions here: https://wiki.alliedmods.net/Building_SourceMod#Mac_OS_X
I get to:
clang/gcc info: