* [Tarantool-patches] [PATCH luajit 0/3] Various fixes for macOS
@ 2025-11-24 20:26 Sergey Kaplun via Tarantool-patches
2025-11-24 20:26 ` [Tarantool-patches] [PATCH luajit 1/3] macOS: Fix macOS 15 / Clang 16 build Sergey Kaplun via Tarantool-patches
` (2 more replies)
0 siblings, 3 replies; 7+ messages in thread
From: Sergey Kaplun via Tarantool-patches @ 2025-11-24 20:26 UTC (permalink / raw)
To: Sergey Bronnikov; +Cc: tarantool-patches
The first patch fixes invalid deduplication code in the VM, which
results in the CI failure on the modern macOS runners [1]. The second
patch is the follow-up, which fixes the regression for old versions of
Xcode. The last one fixes the warning of the linker about the obsolete
flag.
Branch: https://github.com/tarantool/luajit/tree/skaplun/fix-macos-xcode
Related issues:
* https://github.com/LuaJIT/LuaJIT/issues/1266
* https://github.com/LuaJIT/LuaJIT/issues/1275
* https://github.com/LuaJIT/LuaJIT/issues/1283
* https://github.com/LuaJIT/LuaJIT/pull/1284
[1]: https://github.com/tarantool/luajit/actions/runs/18909165892/job/55556930490
Mike Pall (3):
macOS: Fix macOS 15 / Clang 16 build.
macOS: Workaround for buggy XCode 15.0 - 15.2 linker.
macOS: Remove obsolete -single_module flag.
cmake/SetTargetFlags.cmake | 2 +-
src/Makefile.original | 4 ++--
src/host/buildvm_asm.c | 4 ++++
src/vm_arm64.dasc | 1 -
src/vm_x64.dasc | 1 -
src/vm_x86.dasc | 1 -
6 files changed, 7 insertions(+), 6 deletions(-)
--
2.51.2
^ permalink raw reply [flat|nested] 7+ messages in thread* [Tarantool-patches] [PATCH luajit 1/3] macOS: Fix macOS 15 / Clang 16 build. 2025-11-24 20:26 [Tarantool-patches] [PATCH luajit 0/3] Various fixes for macOS Sergey Kaplun via Tarantool-patches @ 2025-11-24 20:26 ` Sergey Kaplun via Tarantool-patches 2025-11-25 13:56 ` Sergey Bronnikov via Tarantool-patches 2025-11-24 20:26 ` [Tarantool-patches] [PATCH luajit 2/3] macOS: Workaround for buggy XCode 15.0 - 15.2 linker Sergey Kaplun via Tarantool-patches 2025-11-24 20:26 ` [Tarantool-patches] [PATCH luajit 3/3] macOS: Remove obsolete -single_module flag Sergey Kaplun via Tarantool-patches 2 siblings, 1 reply; 7+ messages in thread From: Sergey Kaplun via Tarantool-patches @ 2025-11-24 20:26 UTC (permalink / raw) To: Sergey Bronnikov; +Cc: tarantool-patches From: Mike Pall <mike> Note: The -Wl,-no_deduplicate workaround is NOT needed anymore. Thanks to fxcoudert, corsix, clason, baconpaul, mvf. (cherry picked from commit 2240d84464cc3dcb22fd976f1db162b36b5b52d5) When building LuaJIT in the non-Debug mode, the -O2 optimization flag is applied for both the compiler and the linker. Thus, the linker may apply various optimizations, such as code deduplication. Since macOS 15, the bundled Clang provided by Xcode tools may wrongly deduplicate the part of the LuaJIT VM. One workaround may be to provide a flag to the linker `-Wl,-no_deduplicate` [1], which helps to avoid wrong deduplication. The other option is to remove emitting `.subsections_via_symbols` [2] to avoid shrinking the object file by the labels. The second option is more robust, since there is no rationale why this directive was added in the past. [1]: https://rocm.docs.amd.com/projects/llvm-project/en/latest/LLVM/lld/html/MachO/ld64-vs-lld.html [2]: https://reviews.llvm.org/D79926 Sergey Kaplun: * added the description for the problem Part of tarantool/tarantool#11691 --- src/vm_arm64.dasc | 1 - src/vm_x64.dasc | 1 - src/vm_x86.dasc | 1 - 3 files changed, 3 deletions(-) diff --git a/src/vm_arm64.dasc b/src/vm_arm64.dasc index c5f0a7a7..6600e226 100644 --- a/src/vm_arm64.dasc +++ b/src/vm_arm64.dasc @@ -4076,7 +4076,6 @@ static void emit_asm_debug(BuildCtx *ctx) "LEFDEY:\n\n", fcsize); } #endif - fprintf(ctx->fp, ".subsections_via_symbols\n"); } break; #endif diff --git a/src/vm_x64.dasc b/src/vm_x64.dasc index d5296759..8b6781a6 100644 --- a/src/vm_x64.dasc +++ b/src/vm_x64.dasc @@ -4943,7 +4943,6 @@ static void emit_asm_debug(BuildCtx *ctx) "LEFDEY:\n\n", fcsize); } #endif - fprintf(ctx->fp, ".subsections_via_symbols\n"); } break; #endif diff --git a/src/vm_x86.dasc b/src/vm_x86.dasc index b043b830..7c11c78e 100644 --- a/src/vm_x86.dasc +++ b/src/vm_x86.dasc @@ -5853,7 +5853,6 @@ static void emit_asm_debug(BuildCtx *ctx) fprintf(ctx->fp, "L_%s$stub:\n\t.indirect_symbol _%s\n\t.ascii \"\\364\\364\\364\\364\\364\"\n", *xn, *xn); } #endif - fprintf(ctx->fp, ".subsections_via_symbols\n"); } break; #endif -- 2.51.2 ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [Tarantool-patches] [PATCH luajit 1/3] macOS: Fix macOS 15 / Clang 16 build. 2025-11-24 20:26 ` [Tarantool-patches] [PATCH luajit 1/3] macOS: Fix macOS 15 / Clang 16 build Sergey Kaplun via Tarantool-patches @ 2025-11-25 13:56 ` Sergey Bronnikov via Tarantool-patches 0 siblings, 0 replies; 7+ messages in thread From: Sergey Bronnikov via Tarantool-patches @ 2025-11-25 13:56 UTC (permalink / raw) To: Sergey Kaplun; +Cc: tarantool-patches [-- Attachment #1: Type: text/plain, Size: 1457 bytes --] Hi, Sergey! Thanks for the patch! LGTM with a minor comment. Sergey On 11/24/25 23:26, Sergey Kaplun wrote: > From: Mike Pall <mike> > > Note: The -Wl,-no_deduplicate workaround is NOT needed anymore. > Thanks to fxcoudert, corsix, clason, baconpaul, mvf. > > (cherry picked from commit 2240d84464cc3dcb22fd976f1db162b36b5b52d5) > > When building LuaJIT in the non-Debug mode, the -O2 optimization flag is > applied for both the compiler and the linker. Thus, the linker may apply > various optimizations, such as code deduplication. Since macOS 15, the > bundled Clang provided by Xcode tools may wrongly deduplicate the part > of the LuaJIT VM. One workaround may be to provide a flag to the linker > `-Wl,-no_deduplicate` [1], which helps to avoid wrong deduplication. The > other option is to remove emitting `.subsections_via_symbols` [2] to > avoid shrinking the object file by the labels. > > The second option is more robust, since there is no rationale why this > directive was added in the past. > > [1]:https://rocm.docs.amd.com/projects/llvm-project/en/latest/LLVM/lld/html/MachO/ld64-vs-lld.html > [2]:https://reviews.llvm.org/D79926 I would also add a link to Mach-O File Format Reference [1]. We already referred to it in the commit 6e3aad8fb65f20a294171620b2e3bb4a8287e9b3 ("OSX/iOS/ARM64: Fix generation of Mach-O object files."). Feel free to ignore. 1. https://github.com/aidansteele/osx-abi-macho-file-format-reference <snipped> [-- Attachment #2: Type: text/html, Size: 2674 bytes --] ^ permalink raw reply [flat|nested] 7+ messages in thread
* [Tarantool-patches] [PATCH luajit 2/3] macOS: Workaround for buggy XCode 15.0 - 15.2 linker. 2025-11-24 20:26 [Tarantool-patches] [PATCH luajit 0/3] Various fixes for macOS Sergey Kaplun via Tarantool-patches 2025-11-24 20:26 ` [Tarantool-patches] [PATCH luajit 1/3] macOS: Fix macOS 15 / Clang 16 build Sergey Kaplun via Tarantool-patches @ 2025-11-24 20:26 ` Sergey Kaplun via Tarantool-patches 2025-11-26 12:09 ` Sergey Bronnikov via Tarantool-patches 2025-11-24 20:26 ` [Tarantool-patches] [PATCH luajit 3/3] macOS: Remove obsolete -single_module flag Sergey Kaplun via Tarantool-patches 2 siblings, 1 reply; 7+ messages in thread From: Sergey Kaplun via Tarantool-patches @ 2025-11-24 20:26 UTC (permalink / raw) To: Sergey Bronnikov; +Cc: tarantool-patches From: Mike Pall <mike> Thanks to Carlo Cabrera. (cherry picked from commit b2915e9ab55b999429b4d1931097064c4e17de53) The previous commit removes emitting the `.subsections_via_symbols` [1] directive for macOS. Nevertheless, the aforementioned Xcode linker versions produce incorrect code for the VM without this directive. As a fix for old versions of macOS, this patch adds emitting this directive in the buildvm. [1]: https://reviews.llvm.org/D79926 Sergey Kaplun: * added the description for the problem Part of tarantool/tarantool#11691 --- src/host/buildvm_asm.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/host/buildvm_asm.c b/src/host/buildvm_asm.c index 43595b31..fc09d71a 100644 --- a/src/host/buildvm_asm.c +++ b/src/host/buildvm_asm.c @@ -347,6 +347,10 @@ void emit_asm(BuildCtx *ctx) fprintf(ctx->fp, "\t.ident \"%s\"\n", ctx->dasm_ident); break; case BUILD_machasm: +#if defined(__apple_build_version__) && __apple_build_version__ >= 15000000 && __apple_build_version__ < 15000300 + /* Workaround for XCode 15.0 - 15.2. */ + fprintf(ctx->fp, "\t.subsections_via_symbols\n"); +#endif fprintf(ctx->fp, "\t.cstring\n" "\t.ascii \"%s\\0\"\n", ctx->dasm_ident); -- 2.51.2 ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [Tarantool-patches] [PATCH luajit 2/3] macOS: Workaround for buggy XCode 15.0 - 15.2 linker. 2025-11-24 20:26 ` [Tarantool-patches] [PATCH luajit 2/3] macOS: Workaround for buggy XCode 15.0 - 15.2 linker Sergey Kaplun via Tarantool-patches @ 2025-11-26 12:09 ` Sergey Bronnikov via Tarantool-patches 0 siblings, 0 replies; 7+ messages in thread From: Sergey Bronnikov via Tarantool-patches @ 2025-11-26 12:09 UTC (permalink / raw) To: Sergey Kaplun; +Cc: tarantool-patches [-- Attachment #1: Type: text/plain, Size: 2104 bytes --] Hi, Sergey, thanks for the patch! LGTM with a minor comment. Sergey On 11/24/25 23:26, Sergey Kaplun wrote: > From: Mike Pall <mike> > > Thanks to Carlo Cabrera. > > (cherry picked from commit b2915e9ab55b999429b4d1931097064c4e17de53) > > The previous commit removes emitting the `.subsections_via_symbols` [1] > directive for macOS. Nevertheless, the aforementioned Xcode linker > versions produce incorrect code for the VM without this directive. > > As a fix for old versions of macOS, this patch adds emitting this I would add exact macOS versions, according to [1] it is: 15000000 1. https://stackoverflow.com/questions/19387043/how-can-i-reliably-detect-the-version-of-clang-at-preprocessing-time#comment137533353_19391724 > directive in the buildvm. > > [1]:https://reviews.llvm.org/D79926 > > Sergey Kaplun: > * added the description for the problem > > Part of tarantool/tarantool#11691 > --- > src/host/buildvm_asm.c | 4 ++++ > 1 file changed, 4 insertions(+) > > diff --git a/src/host/buildvm_asm.c b/src/host/buildvm_asm.c > index 43595b31..fc09d71a 100644 > --- a/src/host/buildvm_asm.c > +++ b/src/host/buildvm_asm.c > @@ -347,6 +347,10 @@ void emit_asm(BuildCtx *ctx) > fprintf(ctx->fp, "\t.ident \"%s\"\n", ctx->dasm_ident); > break; > case BUILD_machasm: > +#if defined(__apple_build_version__) && __apple_build_version__ >= 15000000 && __apple_build_version__ < 15000300 > + /* Workaround for XCode 15.0 - 15.2. */ __apple_build_version__ defines a macOS version. But macOS 15 includes XCode 16, see [2], not 15.x So there is an inconsistency in condition and comment. I would list macOS versions in a comment like this "Workaround for macOS 15, 15.1 and 15.2" to avoid misinterpretation due to non-strict inequality with 15000300. Also, I would include a link to [2] to the commit message. 2. https://developer.apple.com/documentation/macos-release-notes/macos-15-release-notes > + fprintf(ctx->fp, "\t.subsections_via_symbols\n"); > +#endif > fprintf(ctx->fp, > "\t.cstring\n" > "\t.ascii \"%s\\0\"\n", ctx->dasm_ident); [-- Attachment #2: Type: text/html, Size: 3391 bytes --] ^ permalink raw reply [flat|nested] 7+ messages in thread
* [Tarantool-patches] [PATCH luajit 3/3] macOS: Remove obsolete -single_module flag. 2025-11-24 20:26 [Tarantool-patches] [PATCH luajit 0/3] Various fixes for macOS Sergey Kaplun via Tarantool-patches 2025-11-24 20:26 ` [Tarantool-patches] [PATCH luajit 1/3] macOS: Fix macOS 15 / Clang 16 build Sergey Kaplun via Tarantool-patches 2025-11-24 20:26 ` [Tarantool-patches] [PATCH luajit 2/3] macOS: Workaround for buggy XCode 15.0 - 15.2 linker Sergey Kaplun via Tarantool-patches @ 2025-11-24 20:26 ` Sergey Kaplun via Tarantool-patches 2025-11-26 11:58 ` Sergey Bronnikov via Tarantool-patches 2 siblings, 1 reply; 7+ messages in thread From: Sergey Kaplun via Tarantool-patches @ 2025-11-24 20:26 UTC (permalink / raw) To: Sergey Bronnikov; +Cc: tarantool-patches From: Mike Pall <mike> Thanks to dundargoc. (cherry picked from commit 97813fb924edf822455f91a5fbbdfdb349e5984f) The aforementioned flag is the default since Xcode 2.2 [1]. This patch removes this flag to avoid warnings for modern Xcode versions at the linking stage. [1]: https://bugzilla.mozilla.org/show_bug.cgi?id=1743539#c1 Sergey Kaplun: * added the description for the problem Part of tarantool/tarantool#11691 --- cmake/SetTargetFlags.cmake | 2 +- src/Makefile.original | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/cmake/SetTargetFlags.cmake b/cmake/SetTargetFlags.cmake index d6ee1693..a0f9d45a 100644 --- a/cmake/SetTargetFlags.cmake +++ b/cmake/SetTargetFlags.cmake @@ -47,7 +47,7 @@ if(LUAJIT_ARCH STREQUAL "x86") endif() if(CMAKE_SYSTEM_NAME STREQUAL "Darwin") - AppendFlags(TARGET_SHARED_FLAGS -single_module -undefined dynamic_lookup) + AppendFlags(TARGET_SHARED_FLAGS -undefined dynamic_lookup) else() # Linux and FreeBSD. AppendFlags(TARGET_BIN_FLAGS -Wl,-E) list(APPEND TARGET_LIBS dl) diff --git a/src/Makefile.original b/src/Makefile.original index 8d925e3a..471d692c 100644 --- a/src/Makefile.original +++ b/src/Makefile.original @@ -329,13 +329,13 @@ ifeq (Darwin,$(TARGET_SYS)) endif TARGET_STRIP+= -x TARGET_XCFLAGS+= -DLUAJIT_UNWIND_EXTERNAL - TARGET_XSHLDFLAGS= -dynamiclib -single_module -undefined dynamic_lookup -fPIC + TARGET_XSHLDFLAGS= -dynamiclib -undefined dynamic_lookup -fPIC TARGET_DYNXLDOPTS= TARGET_XSHLDFLAGS+= -install_name $(TARGET_DYLIBPATH) -compatibility_version $(MAJVER).$(MINVER) -current_version $(MAJVER).$(MINVER).$(RELVER) else ifeq (iOS,$(TARGET_SYS)) TARGET_STRIP+= -x - TARGET_XSHLDFLAGS= -dynamiclib -single_module -undefined dynamic_lookup -fPIC + TARGET_XSHLDFLAGS= -dynamiclib -undefined dynamic_lookup -fPIC TARGET_DYNXLDOPTS= TARGET_XSHLDFLAGS+= -install_name $(TARGET_DYLIBPATH) -compatibility_version $(MAJVER).$(MINVER) -current_version $(MAJVER).$(MINVER).$(RELVER) ifeq (arm64,$(TARGET_LJARCH)) -- 2.51.2 ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [Tarantool-patches] [PATCH luajit 3/3] macOS: Remove obsolete -single_module flag. 2025-11-24 20:26 ` [Tarantool-patches] [PATCH luajit 3/3] macOS: Remove obsolete -single_module flag Sergey Kaplun via Tarantool-patches @ 2025-11-26 11:58 ` Sergey Bronnikov via Tarantool-patches 0 siblings, 0 replies; 7+ messages in thread From: Sergey Bronnikov via Tarantool-patches @ 2025-11-26 11:58 UTC (permalink / raw) To: Sergey Kaplun; +Cc: tarantool-patches [-- Attachment #1: Type: text/plain, Size: 2445 bytes --] Hi, Sergey, thanks for the patch! LGTM with two minor comments. Sergey On 11/24/25 23:26, Sergey Kaplun wrote: > From: Mike Pall <mike> > > Thanks to dundargoc. > > (cherry picked from commit 97813fb924edf822455f91a5fbbdfdb349e5984f) > > The aforementioned flag is the default since Xcode 2.2 [1]. You refer to the description in the previous commit, right? I would name a flag here instead > This patch removes this flag to avoid warnings for modern Xcode > versions at the linking stage. it is worth to mention our own modifications for CMake build system > > [1]:https://bugzilla.mozilla.org/show_bug.cgi?id=1743539#c1 > > Sergey Kaplun: > * added the description for the problem > > Part of tarantool/tarantool#11691 > --- > cmake/SetTargetFlags.cmake | 2 +- > src/Makefile.original | 4 ++-- > 2 files changed, 3 insertions(+), 3 deletions(-) > > diff --git a/cmake/SetTargetFlags.cmake b/cmake/SetTargetFlags.cmake > index d6ee1693..a0f9d45a 100644 > --- a/cmake/SetTargetFlags.cmake > +++ b/cmake/SetTargetFlags.cmake > @@ -47,7 +47,7 @@ if(LUAJIT_ARCH STREQUAL "x86") > endif() > > if(CMAKE_SYSTEM_NAME STREQUAL "Darwin") > - AppendFlags(TARGET_SHARED_FLAGS -single_module -undefined dynamic_lookup) > + AppendFlags(TARGET_SHARED_FLAGS -undefined dynamic_lookup) > else() # Linux and FreeBSD. > AppendFlags(TARGET_BIN_FLAGS -Wl,-E) > list(APPEND TARGET_LIBS dl) > diff --git a/src/Makefile.original b/src/Makefile.original > index 8d925e3a..471d692c 100644 > --- a/src/Makefile.original > +++ b/src/Makefile.original > @@ -329,13 +329,13 @@ ifeq (Darwin,$(TARGET_SYS)) > endif > TARGET_STRIP+= -x > TARGET_XCFLAGS+= -DLUAJIT_UNWIND_EXTERNAL > - TARGET_XSHLDFLAGS= -dynamiclib -single_module -undefined dynamic_lookup -fPIC > + TARGET_XSHLDFLAGS= -dynamiclib -undefined dynamic_lookup -fPIC > TARGET_DYNXLDOPTS= > TARGET_XSHLDFLAGS+= -install_name $(TARGET_DYLIBPATH) -compatibility_version $(MAJVER).$(MINVER) -current_version $(MAJVER).$(MINVER).$(RELVER) > else > ifeq (iOS,$(TARGET_SYS)) > TARGET_STRIP+= -x > - TARGET_XSHLDFLAGS= -dynamiclib -single_module -undefined dynamic_lookup -fPIC > + TARGET_XSHLDFLAGS= -dynamiclib -undefined dynamic_lookup -fPIC > TARGET_DYNXLDOPTS= > TARGET_XSHLDFLAGS+= -install_name $(TARGET_DYLIBPATH) -compatibility_version $(MAJVER).$(MINVER) -current_version $(MAJVER).$(MINVER).$(RELVER) > ifeq (arm64,$(TARGET_LJARCH)) [-- Attachment #2: Type: text/html, Size: 3312 bytes --] ^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2025-11-26 12:09 UTC | newest] Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2025-11-24 20:26 [Tarantool-patches] [PATCH luajit 0/3] Various fixes for macOS Sergey Kaplun via Tarantool-patches 2025-11-24 20:26 ` [Tarantool-patches] [PATCH luajit 1/3] macOS: Fix macOS 15 / Clang 16 build Sergey Kaplun via Tarantool-patches 2025-11-25 13:56 ` Sergey Bronnikov via Tarantool-patches 2025-11-24 20:26 ` [Tarantool-patches] [PATCH luajit 2/3] macOS: Workaround for buggy XCode 15.0 - 15.2 linker Sergey Kaplun via Tarantool-patches 2025-11-26 12:09 ` Sergey Bronnikov via Tarantool-patches 2025-11-24 20:26 ` [Tarantool-patches] [PATCH luajit 3/3] macOS: Remove obsolete -single_module flag Sergey Kaplun via Tarantool-patches 2025-11-26 11:58 ` Sergey Bronnikov via Tarantool-patches
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox