Skip to content

Commit 27ee290

Browse files
committed
Compile Lua 5.1 on macOS with -DLUA_USE_LINUX (for other versions keep using -DLUA_USE_MACOSX)
Add `-fno-common` gcc flag
1 parent ba3199f commit 27ee290

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

src/lib.rs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -86,10 +86,13 @@ impl Build {
8686
config.define("LUA_USE_LINUX", None);
8787
}
8888
_ if target.contains("apple-darwin") => {
89-
config.define("LUA_USE_MACOSX", None);
89+
match version {
90+
Lua51 => config.define("LUA_USE_LINUX", None),
91+
_ => config.define("LUA_USE_MACOSX", None),
92+
};
9093
}
91-
_ if target.contains("emscripten") => {}
9294
_ if target.contains("windows") => {
95+
// Defined in Lua >= 5.3
9396
config.define("LUA_USE_WINDOWS", None);
9497
}
9598
_ => panic!("don't know how to build Lua for {}", target),
@@ -108,7 +111,8 @@ impl Build {
108111

109112
config
110113
.include(&source_dir)
111-
.flag("-w")
114+
.flag("-w") // Suppress all warnings
115+
.flag_if_supported("-fno-common") // Compile common globals like normal definitions
112116
.file(source_dir.join("lapi.c"))
113117
.file(source_dir.join("lauxlib.c"))
114118
.file(source_dir.join("lbaselib.c"))

0 commit comments

Comments
 (0)