Open Jack-Punter opened 2 months ago
It looks like this immintrin.h
include is part of the custom layer for audio (which iirc was added in the last release version so was probably an unintended regression, and i believe was pretty experimental POC type work).
@drpriver If you have time would you mind removing the audio system from the custom layer and see if it works without the arch specifier? I'd comment it out here and chase build errors for where its used here: https://github.com/4coder-community/4cc/blob/a0f12509675437453121ddf270a5529ca38f58ab/code/custom/4coder_default_include.cpp#L142 and here: https://github.com/4coder-community/4cc/blob/a0f12509675437453121ddf270a5529ca38f58ab/code/custom/4coder_default_include.cpp#L37
(or alternatively #if 0
out all the implementations in /code/custom/4coder_audio.cpp
)
It looks like the audio system within the core doesn't rely on this header so its just the custom implementation that uses it.
Edit: see next comment for a better patch.
Had to do a few things, but got it building on M1 mac.
non-source/foreign/x64/libfreetype-mac.a
that it links against. I had to alter code/bin/4ed_build.cpp
to use an arm64 build of freetype. I already had one on my system so I copied it to non-source/foreign/arm64/libfreetype-mac.a
The build system still seems to think it’s x64 for naming and such, but it is an arm64 binary.
Proper fix would modify build system logic instead of what I did below.
diff --git a/code/bin/4ed_build.cpp b/code/bin/4ed_build.cpp
index fa0a8e81..02d5694f 100644
--- a/code/bin/4ed_build.cpp
+++ b/code/bin/4ed_build.cpp
@@ -404,8 +404,10 @@ build(Arena *arena, u32 flags, u32 arch, char *code_path, char **code_files, cha
"-framework CoreServices “ \
"-framework OpenGL -framework IOKit -framework Metal -framework MetalKit “
+// #define CLANG_LIBS_X64 CLANG_LIBS_COMMON \
+// FOREIGN "/x64/libfreetype-mac.a”
#define CLANG_LIBS_X64 CLANG_LIBS_COMMON \
-FOREIGN "/x64/libfreetype-mac.a”
+FOREIGN "/arm64/libfreetype-mac.a”
#define CLANG_LIBS_X86 CLANG_LIBS_COMMON \
FOREIGN "/x86/libfreetype-mac.a”
diff --git a/code/custom/4coder_default_hooks.cpp b/code/custom/4coder_default_hooks.cpp
index 90102e53..04d5b706 100644
--- a/code/custom/4coder_default_hooks.cpp
+++ b/code/custom/4coder_default_hooks.cpp
@@ -20,9 +20,11 @@ CUSTOM_DOC("Default command for responding to a startup event”)
}
}
+#if 0
{
def_audio_init();
}
+#endif
{
def_enable_virtual_whitespace = def_get_config_b32(vars_save_string_lit("enable_virtual_whitespace”));
diff --git a/code/custom/4coder_default_include.cpp b/code/custom/4coder_default_include.cpp
index f6221dd9..debb3f3e 100644
--- a/code/custom/4coder_default_include.cpp
+++ b/code/custom/4coder_default_include.cpp
@@ -34,7 +34,7 @@
#include "generated/lexer_cpp.h”
#include “4coder_variables.h”
-#include “4coder_audio.h”
+// #include “4coder_audio.h”
#include “4coder_profile.h”
#include “4coder_async_tasks.h”
#include “4coder_string_match.h”
@@ -139,7 +139,7 @@
#include “4coder_doc_commands.cpp”
#include “4coder_docs.cpp”
#include “4coder_variables.cpp”
-#include “4coder_audio.cpp”
+// #include “4coder_audio.cpp”
#include “4coder_search_list.cpp”
#include “4coder_examples.cpp”
diff --git a/code/custom/4coder_examples.cpp b/code/custom/4coder_examples.cpp
index 20843ce0..1839d193 100644
--- a/code/custom/4coder_examples.cpp
+++ b/code/custom/4coder_examples.cpp
@@ -208,6 +208,7 @@ CUSTOM_DOC("Example of query_user_string and query_user_number”)
}
}
+#if 0
global Audio_Control the_music_control = {};
CUSTOM_COMMAND_SIG(music_start)
@@ -262,6 +263,7 @@ CUSTOM_DOC("Play the hit sound effect”)
index += 1;
}
}
+#endif
// BOTTOM
Apparently _mm_pause()
. A much smaller patch would be:
diff --git a/code/custom/4coder_audio.cpp b/code/custom/4coder_audio.cpp
index fa6a25b5..0c409b60 100644
--- a/code/custom/4coder_audio.cpp
+++ b/code/custom/4coder_audio.cpp
@@ -6,7 +6,11 @@
#include <immintrin.h>
#define _InterlockedExchangeAdd __sync_fetch_and_add
#elif OS_MAC
+#if ARCH_ARM64
+#define _mm_pause() __builtin_arm_yield()
+#else
#include <immintrin.h>
+#endif
#define _InterlockedExchangeAdd __sync_fetch_and_add
#else
#include <intrin.h>
code/bin/4ed_build.cpp
still tries to link against the x64 libfreetype though.
Theres an include for
<immintrin.h>
for https://github.com/4coder-community/4cc/blob/a0f12509675437453121ddf270a5529ca38f58ab/code/custom/4coder_audio.cpp#L6 that prevents us building for on arm. see: https://github.com/4coder-community/4cc/pull/14Looks like this is just in the custom layer, so in theory the core should be build-able on arm.