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

Build failure on Apple Silicon #243

Closed
carlocab opened this issue Jan 21, 2021 · 8 comments · Fixed by #261
Closed

Build failure on Apple Silicon #243

carlocab opened this issue Jan 21, 2021 · 8 comments · Fixed by #261

Comments

@carlocab
Copy link
Contributor

As I mentioned in #242, I'm trying to build luvi on Apple Silicon. However, this fails with a linker error:

ld: missing LC_SEGMENT file 'jitted_tmp/src/lua/init.lua_luvi_generated.o' for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[2]: *** [luvi] Error 1
make[1]: *** [CMakeFiles/luvi.dir/all] Error 2
make: *** [all] Error 2

CI logs available at https://github.com/Homebrew/homebrew-core/pull/69036/checks?check_run_id=1739201673.

The error starts here and the CMake invocation is here.

This compiles successfully on the Intel CI nodes. As previously mentioned, I'm building with a custom libuv (v1.40), a custom LuaJIT (OpenResty v2.1-20201229), and a shared libluv (v1.36.0, built with the aforementioned libuv and LuaJIT).

@carlocab
Copy link
Contributor Author

carlocab commented Jan 21, 2021

There's mention of setting TARGET_ARCH in a9dc8da, but that seems to be only useful for cross-compiling. Still, I thought it might be worth a try [1], but it doesn't help. I still get the exact same error. [2]

[1] Homebrew/homebrew-core@fa3d987
[2] https://github.com/Homebrew/homebrew-core/runs/1739322226#step:7:338

carlocab added a commit to carlocab/homebrew-core that referenced this issue Jan 23, 2021
The formula install block downloads:
- un-checksummed files and pipes one of them into `sh`; and,
- binary executables that are installed into its prefix.

This commit fixes that by bypassing the download and building them all
from source.

Follow up to Homebrew#68787.

One of its resources still does not build for Apple Silicon. Reported
upstream at

    luvit/luvi#243
BrewTestBot pushed a commit to Homebrew/homebrew-core that referenced this issue Jan 23, 2021
The formula install block downloads:
- un-checksummed files and pipes one of them into `sh`; and,
- binary executables that are installed into its prefix.

This commit fixes that by bypassing the download and building them all
from source.

Follow up to #68787.

One of its resources still does not build for Apple Silicon. Reported
upstream at

    luvit/luvi#243

Closes #69036.

Signed-off-by: Seeker <meaningseeking@protonmail.com>
Signed-off-by: BrewTestBot <1589480+BrewTestBot@users.noreply.github.com>
@drveoj
Copy link

drveoj commented Mar 22, 2021

I think this is basically a duplicate of #230 because the apple silicon is basically ARM (aarch64) under the hood. Same error, same place.

@carlocab
Copy link
Contributor Author

Yes, it does look like the same error. Apple ARM isn't exactly the same as aarch64, however. There are still a lot of things that work fine on aarch64 but don't run on Apple Silicon.

@carlocab
Copy link
Contributor Author

Actually, I'm not sure. Is missing LC_SEGMENT file the same as a segfault?

@reasonMix
Copy link

modify the luajit source code.bcsave_machobj function in the bcsave.lua. delete the fat mode, only use the thin mode for apple m1

@carlocab
Copy link
Contributor Author

carlocab commented Jul 1, 2022

modify the luajit source code.bcsave_machobj function in the bcsave.lua. delete the fat mode, only use the thin mode for apple m1

This seems like a likely fix. See LuaJIT/LuaJIT#649.

@carlocab
Copy link
Contributor Author

This is fixed by LuaJIT/LuaJIT#863 and the following patch:

diff --git a/CMakeLists.txt b/CMakeLists.txt
index abb2f15..f27858f 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -170,10 +170,6 @@ lua_add_executable(luvi
   ${lpeg_re_lua}
 )
 
-if(APPLE)
-  set(CMAKE_EXE_LINKER_FLAGS "-pagezero_size 10000 -image_base 100000000 ${CMAKE_EXE_LINKER_FLAGS}")
-endif()
-
 if(${CMAKE_SYSTEM_NAME} MATCHES "FreeBSD")
   set(CMAKE_EXE_LINKER_FLAGS "-Wl,-E")
 endif()

carlocab added a commit to carlocab/luvi that referenced this issue Jul 12, 2022
These flags are no longer necessary and break the build on ARM64.

See LuaJIT/LuaJIT#649.

Partially resolves luvit#243.
@carlocab
Copy link
Contributor Author

Not quite fixed yet, as this still needs LuaJIT/LuaJIT#863. But I suppose that's not really actionable here, so I'm ok to leave this closed.

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

Successfully merging a pull request may close this issue.

3 participants