Skip to content

Commit 83ac919

Browse files
Use more explicit architecture compiler options on Linux
Co-authored-by: Joaquim Monteiro <[email protected]>
1 parent 7598b08 commit 83ac919

File tree

1 file changed

+21
-12
lines changed

1 file changed

+21
-12
lines changed

platform/linuxbsd/detect.py

Lines changed: 21 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -83,20 +83,29 @@ def configure(env: "SConsEnvironment"):
8383
# gdb works fine without it though, so maybe our crash handler could too.
8484
env.Append(LINKFLAGS=["-rdynamic"])
8585

86-
# Cross-compilation
87-
# TODO: Support cross-compilation on architectures other than x86.
88-
host_is_64_bit = sys.maxsize > 2**32
89-
if host_is_64_bit and env["arch"] == "x86_32":
90-
env.Append(CCFLAGS=["-m32"])
91-
env.Append(LINKFLAGS=["-m32"])
92-
elif not host_is_64_bit and env["arch"] == "x86_64":
93-
env.Append(CCFLAGS=["-m64"])
94-
env.Append(LINKFLAGS=["-m64"])
95-
9686
# CPU architecture flags.
97-
if env["arch"] == "rv64":
87+
# TODO: Support cross-compilation on architectures other than x86.
88+
if env["arch"] == "x86_64":
89+
env.Prepend(CFLAGS=["-m64", "-march=x86-64"])
90+
env.Prepend(CXXFLAGS=["-m64", "-march=x86-64"])
91+
env.Prepend(LINKFLAGS=["-m64", "-march=x86-64"])
92+
elif env["arch"] == "x86_32":
93+
env.Prepend(CFLAGS=["-m32", "-march=i686"])
94+
env.Prepend(CXXFLAGS=["-m32", "-march=i686"])
95+
env.Prepend(LINKFLAGS=["-m32", "-march=i686"])
96+
elif env["arch"] == "arm64":
97+
env.Prepend(CFLAGS=["-march=armv8-a"])
98+
env.Prepend(CXXFLAGS=["-march=armv8-a"])
99+
env.Prepend(LINKFLAGS=["-march=armv8-a"])
100+
elif env["arch"] == "arm32":
101+
env.Prepend(CFLAGS=["-march=armv7-a"])
102+
env.Prepend(CXXFLAGS=["-march=armv7-a"])
103+
env.Prepend(LINKFLAGS=["-march=armv7-a"])
104+
elif env["arch"] == "rv64":
98105
# G = General-purpose extensions, C = Compression extension (very common).
99-
env.Append(CCFLAGS=["-march=rv64gc"])
106+
env.Prepend(CFLAGS=["-march=rv64gc"])
107+
env.Prepend(CXXFLAGS=["-march=rv64gc"])
108+
env.Prepend(LINKFLAGS=["-march=rv64gc"])
100109

101110
## Compiler configuration
102111

0 commit comments

Comments
 (0)