Skip to content

Fix Lua Module Build For MacOS Compatibility#3123

Merged
rjd15372 merged 1 commit into
valkey-io:unstablefrom
eifrah-aws:macos-lua-build-errors
Jan 29, 2026
Merged

Fix Lua Module Build For MacOS Compatibility#3123
rjd15372 merged 1 commit into
valkey-io:unstablefrom
eifrah-aws:macos-lua-build-errors

Conversation

@eifrah-aws

@eifrah-aws eifrah-aws commented Jan 29, 2026

Copy link
Copy Markdown
Contributor

This PR fixes various issues with Lua module built on macOS using CMake / Apple Clang.

Summary of changes

The Lua module build configuration has been updated to support macOS in addition to Linux. Two key changes were made to resolve build issues on Apple platforms.

First, the valkeylua shared library now explicitly includes sha1.c and rand.c source files and links against the fpconv library, ensuring all required symbols are available at link time.

Second, the --disable-new-dtags linker flag is now conditionally applied only on Unix systems excluding macOS, since this flag is not supported by the Apple linker.

In addition, enable position independent code compilation for the fpconv static library by setting the POSITION_INDEPENDENT_CODE property. This allows the library to be linked into shared libraries and position-independent executables.

Last, the Lua library filename definition was previously hardcoded to use the .so extension for all platforms. This change conditionally sets the library name based on the target platform: .so for Linux/Unix systems and .dylib for macOS (and other non-Linux Unix systems). This ensures that the correct dynamic library extension is used when loading the Lua module at runtime.

** Generated by CodeLite. **

The Lua module build configuration has been updated to support macOS in
addition to Linux. Two key changes were made to resolve build issues on
Apple platforms.

First, the valkeylua shared library now explicitly includes `sha1.c` and
`rand.c` source files and links against the fpconv library, ensuring all
required symbols are available at link time.

Second, the --disable-new-dtags linker flag is now conditionally applied
only on Unix systems excluding macOS, since this flag is not supported by
the Apple linker.

In addition, enable position independent code compilation for the fpconv static library
by setting the `POSITION_INDEPENDENT_CODE` property. This allows the library
to be linked into shared libraries and position-independent executables.

Last, the Lua library filename definition was previously hardcoded to use the
`.so` extension for all platforms. This change conditionally sets the
library name based on the target platform: `.so` for Linux/Unix systems
and `.dylib` for macOS (and other non-Linux Unix systems). This ensures
that the correct dynamic library extension is used when loading the Lua
module at runtime.

** Generated by CodeLite. **

Signed-off-by: Eran Ifrah <eifrah@amazon.com>
@codecov

codecov Bot commented Jan 29, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 74.68%. Comparing base (8a9c371) to head (58f9430).
⚠️ Report is 4 commits behind head on unstable.

Additional details and impacted files
@@             Coverage Diff              @@
##           unstable    #3123      +/-   ##
============================================
- Coverage     74.87%   74.68%   -0.20%     
============================================
  Files           129      129              
  Lines         71199    71199              
============================================
- Hits          53310    53172     -138     
- Misses        17889    18027     +138     

see 26 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@ranshid ranshid requested a review from rjd15372 January 29, 2026 11:27
@rainsupreme

Copy link
Copy Markdown
Contributor

Is this build tested in our workflows? I assume not, since they were passing before this fix

@rjd15372 rjd15372 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for fixing this in CMake

@rjd15372

Copy link
Copy Markdown
Member

Is this build tested in our workflows? I assume not, since they were passing before this fix

Yeah, we currently only test the makefile build in macos on our workflows.

@rjd15372 rjd15372 merged commit b8650a5 into valkey-io:unstable Jan 29, 2026
37 of 38 checks passed
harrylin98 pushed a commit to harrylin98/valkey_forked that referenced this pull request Feb 19, 2026
This PR fixes various issues with Lua module built on macOS using CMake
/ Apple Clang.

## Summary of changes

The Lua module build configuration has been updated to support macOS in
addition to Linux. Two key changes were made to resolve build issues on
Apple platforms.

First, the valkeylua shared library now explicitly includes `sha1.c` and
`rand.c` source files and links against the fpconv library, ensuring all
required symbols are available at link time.

Second, the --disable-new-dtags linker flag is now conditionally applied
only on Unix systems excluding macOS, since this flag is not supported
by the Apple linker.

In addition, enable position independent code compilation for the fpconv
static library by setting the `POSITION_INDEPENDENT_CODE` property. This
allows the library to be linked into shared libraries and
position-independent executables.

Last, the Lua library filename definition was previously hardcoded to
use the `.so` extension for all platforms. This change conditionally
sets the library name based on the target platform: `.so` for Linux/Unix
systems and `.dylib` for macOS (and other non-Linux Unix systems). This
ensures that the correct dynamic library extension is used when loading
the Lua module at runtime.

** Generated by CodeLite. **

Signed-off-by: Eran Ifrah <eifrah@amazon.com>
hpatro pushed a commit to hpatro/valkey that referenced this pull request Mar 5, 2026
This PR fixes various issues with Lua module built on macOS using CMake
/ Apple Clang.

## Summary of changes

The Lua module build configuration has been updated to support macOS in
addition to Linux. Two key changes were made to resolve build issues on
Apple platforms.

First, the valkeylua shared library now explicitly includes `sha1.c` and
`rand.c` source files and links against the fpconv library, ensuring all
required symbols are available at link time.

Second, the --disable-new-dtags linker flag is now conditionally applied
only on Unix systems excluding macOS, since this flag is not supported
by the Apple linker.

In addition, enable position independent code compilation for the fpconv
static library by setting the `POSITION_INDEPENDENT_CODE` property. This
allows the library to be linked into shared libraries and
position-independent executables.

Last, the Lua library filename definition was previously hardcoded to
use the `.so` extension for all platforms. This change conditionally
sets the library name based on the target platform: `.so` for Linux/Unix
systems and `.dylib` for macOS (and other non-Linux Unix systems). This
ensures that the correct dynamic library extension is used when loading
the Lua module at runtime.

** Generated by CodeLite. **

Signed-off-by: Eran Ifrah <eifrah@amazon.com>
Signed-off-by: Harkrishn Patro <bunty.hari@gmail.com>
@eifrah-aws eifrah-aws deleted the macos-lua-build-errors branch May 11, 2026 08:26
@eifrah-aws eifrah-aws restored the macos-lua-build-errors branch June 1, 2026 07:36
@eifrah-aws eifrah-aws deleted the macos-lua-build-errors branch June 1, 2026 07:37
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 this pull request may close these issues.

3 participants