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

Update luajitlib #7929

Merged
merged 3 commits into from
Dec 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 0 additions & 5 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -141,11 +141,6 @@ if(CMAKE_CXX_COMPILER_ID MATCHES "Clang|GNU")
-faligned-allocation
-fasm-blocks
)

# LuaJit + XCode 16 goes blammo
add_link_options(
-Wl,-no_deduplicate
)
endif()
elseif(CMAKE_CXX_COMPILER_ID MATCHES "^GNU$")
# GCC only
Expand Down
6 changes: 3 additions & 3 deletions libs/luajitlib/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ luajitlib is a collection of scripts and a CMake configuration that attempts to

## Troubleshooting

CMake should output a series of debug messages and a general error message when a build fails and examining these messages is the first step to troubleshoot the problem. See the sections below for more information on specific use scenarios and platforms and refer to the LuaJIT documentation [here](https://luajit.org/install.html) for more information. The `build-[platform]-luajit.*` scripts in the luajitlib directory can also be ran manually by adding a `"[builddir]"` parameter to test without CMake.
CMake should output a series of debug messages and a general error message when a build fails and examining these messages is the first step to troubleshoot the problem. See the sections below for more information on specific use scenarios and platforms and refer to the LuaJIT documentation [here](https://luajit.org/install.html) for more information. The `build-[platform]-luajit.*` scripts in the luajitlib directory can also be run manually by adding a `"[builddir]"` parameter to test without CMake.

Alternatively, a pre-built statically linked library can be placed directly in the build output directory at `[builddir]/libs/luajitlib/bin` with the header files in `[builddir]/libs/luajitlib/include`. If named either `libluajit.a` or `lua51.lib`, it should be automatically detected and used instead of compiling LuaJIT from source during the CMake configuration process.

Finally, if all other options fail, Lua support can be disabled altogether by adding `-DSURGE_SKIP_LUA=TRUE` in the CMake configuration options.
Finally, if all other options fail, Lua support can be disabled altogether by adding `-DSURGE_SKIP_LUA=TRUE` to the CMake configuration options.

### Cross-compiling

Expand All @@ -20,7 +20,7 @@ The macOS build script attempts to build both `arm64` and `x86_64` binaries usin

### *nix

On Unix-like platforms (including macOS), the default is to use the `amalg` build target, which allows for better optimization at the cost of increased memory use during the compiling process. Removing the `amalg` option in the build scripts could help prevent memory use related issues on some systems.
On Unix-like platforms (including macOS), the default is to use the `amalg` build target, which allows for better optimization at the cost of increased memory use during the compiling process. Removing the `amalg` option in the build scripts could help prevent memory usage related issues on some systems.

### Windows + MSVC

Expand Down
4 changes: 2 additions & 2 deletions libs/luajitlib/build-macos-luajit.sh
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,11 @@ cd "${SD}/LuaJIT" || error=1
export MACOSX_DEPLOYMENT_TARGET=10.9

# Pipe output to /dev/null to suppress linker errors
make amalg -j HOST_CC="clang -target `uname -m`-apple-macos10.9" TARGET_CC="xcrun --toolchain arm64 clang -target arm64-apply-macos10.9 -isysroot $(xcrun --sdk macosx --show-sdk-path) -fvisibility=hidden -fvisibility-inlines-hidden" TARGET_LDFLAGS="-Wl,-no_deduplicate" TARGET_CFLAGS="-O3" > /dev/null 2>&1
make amalg -j HOST_CC="clang -target `uname -m`-apple-macos10.9" TARGET_CC="xcrun --toolchain arm64 clang -target arm64-apply-macos10.9 -isysroot $(xcrun --sdk macosx --show-sdk-path) -fvisibility=hidden -fvisibility-inlines-hidden" TARGET_CFLAGS="-O3" > /dev/null 2>&1
cp src/lib*a "${OD}/arm64" || error=1

make clean || error=1
make amalg -j HOST_CC="clang -target `uname -m`-apple-macos10.9" TARGET_CC="xcrun --toolchain x86_64 clang -target x86_64-apply-macos10.9 -isysroot $(xcrun --sdk macosx --show-sdk-path) -fvisibility=hidden -fvisibility-inlines-hidden" TARGET_LDFLAGS="-Wl,-no_deduplicate" TARGET_CFLAGS="-O3" > /dev/null 2>&1
make amalg -j HOST_CC="clang -target `uname -m`-apple-macos10.9" TARGET_CC="xcrun --toolchain x86_64 clang -target x86_64-apply-macos10.9 -isysroot $(xcrun --sdk macosx --show-sdk-path) -fvisibility=hidden -fvisibility-inlines-hidden" TARGET_CFLAGS="-O3" > /dev/null 2>&1
cp src/lib*a "${OD}/x86_64" || error=1

lipo -create -arch arm64 "${OD}/arm64/libluajit.a" -arch x86_64 "${OD}/x86_64/libluajit.a" -output "${OD}/libluajit.a" || error=1
Expand Down
13 changes: 10 additions & 3 deletions libs/luajitlib/msvcbuild.bat
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ buildvm -m folddef -o lj_folddef.h lj_opt_fold.c
@if "%1"=="static" goto :STATIC
%LJCOMPILE% %LJDYNBUILD% lj_*.c lib_*.c
@if errorlevel 1 goto :BAD
%LJLINK% /DLL /out:%LJDLLNAME% lj_*.obj lib_*.obj
%LJLINK% /DLL /OUT:%LJDLLNAME% lj_*.obj lib_*.obj
@if errorlevel 1 goto :BAD
@goto :MTDLL
:STATIC
Expand All @@ -116,17 +116,24 @@ buildvm -m folddef -o lj_folddef.h lj_opt_fold.c
@if errorlevel 1 goto :BAD
@goto :MTDLL
:AMALGDLL
@if "%2"=="static" goto :AMALGSTATIC
%LJCOMPILE% %LJDYNBUILD% ljamalg.c
@if errorlevel 1 goto :BAD
%LJLINK% /DLL /out:%LJDLLNAME% ljamalg.obj lj_vm.obj
%LJLINK% /DLL /OUT:%LJDLLNAME% ljamalg.obj lj_vm.obj
@if errorlevel 1 goto :BAD
@goto :MTDLL
:AMALGSTATIC
%LJCOMPILE% ljamalg.c
@if errorlevel 1 goto :BAD
%LJLINK% /OUT:%LJDLLNAME% ljamalg.obj lj_vm.obj
@if errorlevel 1 goto :BAD
:MTDLL
if exist %LJDLLNAME%.manifest^
%LJMT% -manifest %LJDLLNAME%.manifest -outputresource:%LJDLLNAME%;2

%LJCOMPILE% luajit.c
@if errorlevel 1 goto :BAD
%LJLINK% /out:luajit.exe luajit.obj %LJLIBNAME%
%LJLINK% /OUT:luajit.exe luajit.obj %LJLIBNAME%
@if errorlevel 1 goto :BAD
if exist luajit.exe.manifest^
%LJMT% -manifest luajit.exe.manifest -outputresource:luajit.exe
Expand Down
Loading