Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MacOS Sonoma 14.3 Compile #167

Closed
fmazur opened this issue Feb 8, 2024 · 12 comments
Closed

MacOS Sonoma 14.3 Compile #167

fmazur opened this issue Feb 8, 2024 · 12 comments

Comments

@fmazur
Copy link

fmazur commented Feb 8, 2024

EDIT: M1 Max arm64

I've installed all dependencies required by the make with MacPorts (there were few missing on the https://github.com/Garux/netradiant-custom/blob/master/COMPILING )

gcc/g++ clang version 14.0.3 (clang-1403.0.22.14.1) arm64-apple-darwin23.3.0
xcode 14.3.1 (and then tried again with 15.2 - latest)

Attempting to build netradiant-custom-latest gives out errors during compile.

[fmazur@freya ~/Games/netradiant-custom-latest]$ make

checking that the build tools exist
Checking for /bin/sh (bash (or another shell))... found.
Checking for echo (coreutils)... found.
Checking for /bin/echo -n (coreutils)... found.
Checking for cat (coreutils)... found.
Checking for mkdir -p (coreutils)... found.
Checking for cp (coreutils)... found.
Checking for cp -r (coreutils)... found.
Checking for rm -f (coreutils)... found.
Checking for rm -f -r (coreutils)... found.
Checking for mv (coreutils)... found.
Checking for echo test | tee /dev/stderr (coreutils)... found.
Checking for sed (sed)... found.
Checking for find (findutils)... found.
Checking for diff (diff)... found.
Checking for cc (gcc)... found.
Checking for c++ (g++)... found.
Checking for ranlib (binutils)... found.
Checking for ar (binutils)... found.
Checking for pkg-config (pkg-config)... found.
Checking for unzip (unzip)... found.
Checking for git (git-core)... found.
Checking for svn (subversion)... found.
Checking for wget (wget)... found.
Checking for otool (xcode)... found.
All required tools have been found!

checking that the dependencies exist
Checking for jpeglib.h (libjpeg8-dev)... found and links.
Checking for glib.h (libglib2.0-dev)... found and links.
Checking for libxml/xpath.h (libxml2-dev)... found and links.
Checking for png.h (libpng12-dev)... found and links.
Checking for GL/gl.h (mesa-common-dev (or another OpenGL library))... found and links.
Checking for QCoreApplication (Qt5Core)... found and links.
Checking for QGuiApplication (Qt5Gui)... found and links.
Checking for QApplication (Qt5Widgets)... found and links.
Checking for dlfcn.h (libc6-dev)... found and links.
Checking for zlib.h (zlib1g-dev)... found and links.
All required libraries have been found!

Compile errors at

...
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/v1/__tuple:283:5: error: static_assert failed due to requirement '0UL < sizeof...(_Types)' "tuple_element index out of range"
    static_assert(_Ip < sizeof...(_Types), "tuple_element index out of range");
    ^             ~~~~~~~~~~~~~~~~~~~~~~~
...
3 warnings and 1 error generated.
make: *** [tools/quake3/q3map2/autopk3.o] Error 1

Am I missing some dependency or compile flags?

@Garux
Copy link
Owner

Garux commented Feb 8, 2024

Please give more of error log, can't prompt w/o exact context.
Clang is always extra picky and requires code tuning.

@fmazur
Copy link
Author

fmazur commented Feb 8, 2024

Please give more of error log, can't prompt w/o exact context. Clang is always extra picky and requires code tuning.

Here is full make log after make clean: https://pastebin.com/z1SHRUQJ

@Garux
Copy link
Owner

Garux commented Feb 8, 2024

I pushed branch with fix of this one https://github.com/Garux/netradiant-custom/tree/Qt-macOS2

@fmazur
Copy link
Author

fmazur commented Feb 8, 2024

I pushed branch with fix of this one https://github.com/Garux/netradiant-custom/tree/Qt-macOS2

Thank you! It resolved that issue. I'm stuck on next part. I've verified that X11 is working and that I can run X11 applications.
Paths that linker is looking for are there.

[fmazur@freya ~]$ ls /usr/X11
bin	etc	include	lib	libexec	share	var
[fmazur@freya ~]$ ls /usr/X11R6
bin	etc	include	lib	libexec	share	var

After cpp/c compile finished it tired to do install/libassimp_.dylib and install/q3map2.arm64:
https://pastebin.com/cPziej6J

I've zlib and assimp installed and exported before compile

export LDFLAGS="-L/opt/homebrew/opt/zlib/lib"
export CPPFLAGS="-I/opt/homebrew/opt/zlib/include"

I'm unable to debug this myself.

@Garux
Copy link
Owner

Garux commented Feb 8, 2024

This is commit, which enabled mac build the other day f7d120f. I believe unzip.cpp part is your stuff.
These funcs likely were force-present in environment b4 and thus disabled.

@fmazur
Copy link
Author

fmazur commented Feb 8, 2024

This is commit, which enabled mac build the other day f7d120f. I believe unzip.cpp part is your stuff. These funcs likely were force-present in environment b4 and thus disabled.

unzip is provided by system on M1 machines.
I've reverted the commit to restore MACLIBDIR. I've added /opt/local/lib to the path. (that's the path that contains X11 etc, not /usr/local/lib from what I've checked)

Here is a list of libs that are in MACLIBDIR, active ports and full compile log
https://pastebin.com/5cJmJngU
https://pastebin.com/hTNGQKLG

I'm not familiar with clang stuff so best I can do i try stuff and provide logs.

@Garux
Copy link
Owner

Garux commented Feb 8, 2024

Have you surely removed ifdefs/recompiled? Because lets see the 1st one, it's not there, when it's disabled by ifdefs
image
And it was exactly the problem the other time.

@fmazur
Copy link
Author

fmazur commented Feb 9, 2024

Right. I was confused for a bit, thought I just had to revert that commit and not cherry-pick.
After cherry-picking that commit that removed ifdefs and updating MACLIBDIR it continued to build but it hangs on something.

[fmazur@freya ~/Games/netradiant-custom]$ git diff
diff --git a/Makefile b/Makefile
index 8cc8a972..d39dc3ee 100644
--- a/Makefile
+++ b/Makefile
@@ -232,7 +232,7 @@ ifeq ($(OS),Darwin)
        CPPFLAGS_COMMON += -DPOSIX -DXWINDOWS
        CFLAGS_COMMON += -fPIC
        CXXFLAGS_COMMON += -fno-exceptions -fno-rtti
-       MACLIBDIR ?= /usr/local/lib
+       MACLIBDIR ?= /opt/local/lib
        CPPFLAGS_COMMON += -I$(MACLIBDIR)/../include -I/usr/X11R6/include
        LDFLAGS_COMMON += -L$(MACLIBDIR) -L/usr/X11R6/lib
        LDFLAGS_DLL += -dynamiclib -ldl
diff --git a/tools/mbspc/qcommon/q_platform.h b/tools/mbspc/qcommon/q_platform.h
index d3b3b6b0..a11b0198 100644
--- a/tools/mbspc/qcommon/q_platform.h
+++ b/tools/mbspc/qcommon/q_platform.h
@@ -156,6 +156,9 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #define idx64 1
 #define ARCH_STRING "x86_64"
 #define Q3_LITTLE_ENDIAN
+#elif defined __aarch64__
+#define ARCH_STRING "arm64"
+#define Q3_LITTLE_ENDIAN
 #endif

 #define DLL_EXT ".dylib"

Had to define arm section for q_platform as it errored out on unsupported platform and endianness which made it not appear anymore?
End of build log with nm output for CurrentDirectory method from libassimp_.dylib and contents of install folder https://pastebin.com/zkH9t4Hb

Each time I clean build and builds are in arm64. I'll try to revert the f7d120f commit and try to build in i386 maybe?

@Garux
Copy link
Owner

Garux commented Feb 9, 2024

Great, so now linker can't find assmodel.dylib.
-Wl,-rpath '-Wl,$ORIGIN/..' is the trick to find it in linux; in windows it works out of the box.
Idk what's the way for mac now, the other time it was linked normally, but missing in runtime; fix was:

% install_name_tool -change install/libassimp_.dylib @executable_path/libassimp_.dylib assmodel.dylib

(for assmodel.dylib particularly)

@fmazur
Copy link
Author

fmazur commented Feb 9, 2024

That would probably work if assmodel.dylib existed but it doesn't get compiled.

[fmazur@freya ~/Games/netradiant-custom]$ install_name_tool -change install/libassimp_.dylib @executable_path/libassimp_.dylib assmodel.dylib
error: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/install_name_tool: can't open file: assmodel.dylib (No such file or directory)

I presume the $$ORIGIN trick could be replaced with -Wl,-rpath,@loader_path/.. -Wl,-rpath,@executable_path/.. for M1

Not sure whether you need full log but here is end part with the changed $$ORIGIN
https://pastebin.com/wZBU7vTR

[fmazur@freya ~/Games/netradiant-custom]$ ls install/
h2data			libassimp_.dylib	q2map.arm64		qdata3.arm64
h2data.arm64		q2map			qdata3

I presume libassimp_.dylib is not complete (4,3mb)

There is assimp available in /opt/local/lib/libassimp.dylib and /opt/local/include/assimp and there is assimp in project libs. I assume this is to build against custom assimp?

@Garux
Copy link
Owner

Garux commented Feb 9, 2024

I mixed up, was meant to say

Great, so now linker can't find libassimp_.dylib

4,3mb is okay; building own version of assimp because at the time of adding it required adjustments to have it usable and for stability.

Oh, and -Wl,-rpath '-Wl,$ORIGIN/..' is related to finding dylib in runtime.
Current problem is linker not finding assimp from -lassimp_ -Linstall prompts (or less likely broken assimp build).

May be lets contact in some discord to enfasten this, my id is 246624639655215114 there.

@fmazur
Copy link
Author

fmazur commented Feb 10, 2024

After honing out remaining M1 quirks I was able to make on M1. Here is more or less updated guide since I don't have access to clean env:

ARM M1 Max
Darwin freya 23.3.0 Darwin Kernel Version 23.3.0: Wed Dec 20 21:30:44 PST 2023; root:xnu-10002.81.5~7/RELEASE_ARM64_T6000 arm64

environment:

  • OS X 14.3

  • Xcode 15.2

  • X11 provided by Xquatz 2.8.5

  • MacPorts 2.9.1-14-Sonoma, homebrew installed

  • the following packages installed:
    Macports:
    gtkglext pkgconfig glib2-devel libxml2 gtk2 pango atk gettext wget assimp Qt5Core Qt5Gui Qt5Widgets subversion xorg zlib zstd

    Branch Qt-macOS2-M1 ( after being merged Fix quirks preventing building on arm #169 - Qt-macOS2 )
    Locate your lib folder either /usr/local/lib or /opt/local/lib ( mine was the /opt/local/lib ) and update Makefile MACLIBDIR path
    There were issues with linking -lassimp_ . I had luck using port installed assimp -lassimp (assimp 5.3.1)

    I'm not sure which packaged are needed after subversion since xorg may have been provided by xquartz but check whether /usr/X11R6 and /usr/X11 directories exist.

build:
run 'make -j16'

run:
./install/radiant.arm64

Edit: Crossed out packages that are most likely not needed.

@fmazur fmazur closed this as completed Feb 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants