Skip to content

Commit

Permalink
Merge pull request godotengine#84307 from akien-mga/linux-crosscompil…
Browse files Browse the repository at this point in the history
…e-remove-hardcoded-lib-path

Linux: Remove hardcoded lib path for x86 cross-compilation
  • Loading branch information
akien-mga committed Nov 1, 2023
2 parents b797f6c + 63153c9 commit e07b3ee
Showing 1 changed file with 10 additions and 11 deletions.
21 changes: 10 additions & 11 deletions platform/linuxbsd/detect.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,16 @@ def configure(env: "Environment"):
# gdb works fine without it though, so maybe our crash handler could too.
env.Append(LINKFLAGS=["-rdynamic"])

# Cross-compilation
# TODO: Support cross-compilation on architectures other than x86.
host_is_64_bit = sys.maxsize > 2**32
if host_is_64_bit and env["arch"] == "x86_32":
env.Append(CCFLAGS=["-m32"])
env.Append(LINKFLAGS=["-m32"])
elif not host_is_64_bit and env["arch"] == "x86_64":
env.Append(CCFLAGS=["-m64"])
env.Append(LINKFLAGS=["-m64"])

# CPU architecture flags.
if env["arch"] == "rv64":
# G = General-purpose extensions, C = Compression extension (very common).
Expand Down Expand Up @@ -469,22 +479,11 @@ def configure(env: "Environment"):
if platform.system() == "FreeBSD":
env.Append(LINKFLAGS=["-lkvm"])

## Cross-compilation
# TODO: Support cross-compilation on architectures other than x86.
host_is_64_bit = sys.maxsize > 2**32
if host_is_64_bit and env["arch"] == "x86_32":
env.Append(CCFLAGS=["-m32"])
env.Append(LINKFLAGS=["-m32", "-L/usr/lib/i386-linux-gnu"])
elif not host_is_64_bit and env["arch"] == "x86_64":
env.Append(CCFLAGS=["-m64"])
env.Append(LINKFLAGS=["-m64", "-L/usr/lib/i686-linux-gnu"])

# Link those statically for portability
if env["use_static_cpp"]:
env.Append(LINKFLAGS=["-static-libgcc", "-static-libstdc++"])
if env["use_llvm"] and platform.system() != "FreeBSD":
env["LINKCOM"] = env["LINKCOM"] + " -l:libatomic.a"

else:
if env["use_llvm"] and platform.system() != "FreeBSD":
env.Append(LIBS=["atomic"])

0 comments on commit e07b3ee

Please sign in to comment.