Skip to content
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
2 changes: 1 addition & 1 deletion modules/gmake/tests/test_gmake_ldflags.lua
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,6 @@ ALL_LDFLAGS += $(LDFLAGS) -L/usr/lib32 -m32
system (p.MACOSX)
prepare()
test.capture [[
ALL_LDFLAGS += $(LDFLAGS) -m64
ALL_LDFLAGS += $(LDFLAGS) -arch x86_64
]]
end
2 changes: 1 addition & 1 deletion modules/gmakelegacy/tests/cpp/test_ldflags.lua
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,6 @@
system (p.MACOSX)
prepare()
test.capture [[
ALL_LDFLAGS += $(LDFLAGS) -m64
ALL_LDFLAGS += $(LDFLAGS) -arch x86_64
]]
end
6 changes: 2 additions & 4 deletions src/tools/clang.lua
Original file line number Diff line number Diff line change
Expand Up @@ -233,12 +233,10 @@
--

clang.ldflags = {
architecture = {
x86 = "-m32",
x86_64 = "-m64",
architecture = table.merge(gcc.ldflags.architecture, {
WASM32 = "-m32",
WASM64 = "-m64",
},
}),
linkerfatalwarnings = {
All = "-Wl,--fatal-warnings",
},
Expand Down
10 changes: 6 additions & 4 deletions src/tools/gcc.lua
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,9 @@
--
gcc.shared = {
architecture = {
x86 = "-m32",
x86_64 = "-m64",
x86 = function (cfg) return iif(cfg.system == p.MACOSX, "-arch i386", "-m32") end,
x86_64 = function (cfg) return iif(cfg.system == p.MACOSX, "-arch x86_64", "-m64") end,
ARM64 = function (cfg) return iif(cfg.system == p.MACOSX, "-arch arm64", nil) end,
},
fatalwarnings = {
All = "-Werror",
Expand Down Expand Up @@ -485,8 +486,9 @@

gcc.ldflags = {
architecture = {
x86 = "-m32",
x86_64 = "-m64",
x86 = function (cfg) return iif(cfg.system == p.MACOSX, "-arch i386", "-m32") end,
x86_64 = function (cfg) return iif(cfg.system == p.MACOSX, "-arch x86_64", "-m64") end,
ARM64 = function (cfg) return iif(cfg.system == p.MACOSX, "-arch arm64", nil) end,
},
linkerfatalwarnings = {
All = "-Wl,--fatal-warnings",
Expand Down
74 changes: 74 additions & 0 deletions tests/tools/test_clang.lua
Original file line number Diff line number Diff line change
Expand Up @@ -237,3 +237,77 @@ end
test.contains({ "-pg" }, clang.getcxxflags(cfg))
test.contains({ "-pg" }, clang.getldflags(cfg))
end

--
-- Make sure system or architecture flags are added properly.
--

function suite.cflags_onX86()
architecture "x86"
prepare()
test.contains({ "-m32" }, clang.getcflags(cfg))
end

function suite.ldflags_onX86()
architecture "x86"
prepare()
test.contains({ "-m32" }, clang.getldflags(cfg))
end

function suite.cflags_onX86_64()
architecture "x86_64"
prepare()
test.contains({ "-m64" }, clang.getcflags(cfg))
end

function suite.ldflags_onX86_64()
architecture "x86_64"
prepare()
test.contains({ "-m64" }, clang.getldflags(cfg))
end

function suite.cflags_macosx_onX86()
system "macosx"
architecture "x86"
prepare()
test.excludes({ "-m32" }, clang.getcflags(cfg))
test.contains({ "-arch i386" }, clang.getcflags(cfg))
end

function suite.ldflags_macosx_onX86()
system "macosx"
architecture "x86"
prepare()
test.excludes({ "-m32" }, clang.getldflags(cfg))
test.contains({ "-arch i386" }, clang.getldflags(cfg))
end

function suite.cflags_macosx_onX86_64()
system "macosx"
architecture "x86_64"
prepare()
test.excludes({ "-m64" }, clang.getcflags(cfg))
test.contains({ "-arch x86_64" }, clang.getcflags(cfg))
end

function suite.ldflags_macosx_onX86_64()
system "macosx"
architecture "x86_64"
prepare()
test.excludes({ "-m64" }, clang.getldflags(cfg))
test.contains({ "-arch x86_64" }, clang.getldflags(cfg))
end

function suite.cflags_macosx_onarm64()
system "macosx"
architecture "arm64"
prepare()
test.contains({ "-arch arm64" }, clang.getcflags(cfg))
end

function suite.ldflags_macosx_onarm64()
system "macosx"
architecture "arm64"
prepare()
test.contains({ "-arch arm64" }, clang.getldflags(cfg))
end
46 changes: 46 additions & 0 deletions tests/tools/test_gcc.lua
Original file line number Diff line number Diff line change
Expand Up @@ -606,6 +606,52 @@
test.contains({ "-m64" }, gcc.getldflags(cfg))
end

function suite.cflags_macosx_onX86()
system "macosx"
architecture "x86"
prepare()
test.excludes({ "-m32" }, gcc.getcflags(cfg))
test.contains({ "-arch i386" }, gcc.getcflags(cfg))
end

function suite.ldflags_macosx_onX86()
system "macosx"
architecture "x86"
prepare()
test.excludes({ "-m32" }, gcc.getldflags(cfg))
test.contains({ "-arch i386" }, gcc.getldflags(cfg))
end

function suite.cflags_macosx_onX86_64()
system "macosx"
architecture "x86_64"
prepare()
test.excludes({ "-m64" }, gcc.getcflags(cfg))
test.contains({ "-arch x86_64" }, gcc.getcflags(cfg))
end

function suite.ldflags_macosx_onX86_64()
system "macosx"
architecture "x86_64"
prepare()
test.excludes({ "-m64" }, gcc.getldflags(cfg))
test.contains({ "-arch x86_64" }, gcc.getldflags(cfg))
end

function suite.cflags_macosx_onarm64()
system "macosx"
architecture "arm64"
prepare()
test.contains({ "-arch arm64" }, gcc.getcflags(cfg))
end

function suite.ldflags_macosx_onarm64()
system "macosx"
architecture "arm64"
prepare()
test.contains({ "-arch arm64" }, gcc.getldflags(cfg))
end


--
-- Non-Windows shared libraries should marked as position independent.
Expand Down