Repository navigation
Allow extra C++ flags and include dirs via the environment - #8
Merged
Merged
Conversation
The vendored Luau sources are compiled by this crate on behalf of mlua-sys, so a consumer several levels up has no way to influence the build. Projects needing a compiler flag for correctness rather than taste currently have to vendor the whole crate to get one in. Read LUAU_CXXFLAGS (whitespace separated) and LUAU_INCLUDE_DIRS (path separated), and declare both with rerun-if-env-changed so changing them forces a rebuild rather than silently reusing an artifact compiled with the old settings. The motivating case is a deterministic simulation: it needs -ffp-contract=off so the modulo expansion cannot fuse into a multiply-add on some architectures and not others, and a force-included header redirecting the libm functions IEEE 754 leaves unspecified.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Hey there! Long time no chat, I've picked back up using mlua as part of porting a game I was working on from being written entirely in Lua on top of Love2D to instead be a hand-written Rust project that provides modding capabilities via mlua.
My challenge is that the game needs to be deterministic including user-created mods written in Lua. I've managed to handle most determinism by shadowing
math.*, but operators like^and^=can't be shadowed in the same way. To solve this, I have to force-include a header that redirects the libm functions IEEE 754 leaves unspecified to my own implementations, which catches^and^=at runtime. The problem is there's no way to pass a compiler flag, so this opens that up for me.AI helped me figure this out, as a heads up. To my understanding, I just need to read
LUAU_CXXFLAGS(whitespace separated) andLUAU_INCLUDE_DIRS(path separated), and declare both withrerun-if-env-changedso changing them forces a rebuild rather than silently reusing an artifact compiled with the old settings.Also, for clarity, I made this PR even though
ccalready picks upCXXFLAGSbecause nothing declarescargo:rerun-if-env-changedfor it, so changing the value doesn't trigger a rebuild, which means you silently get an artifact compiled with the old flags while the build reports success.