浏览代码

Linux: Remove hardcoded lib path for x86 cross-compilation

This breaks the build with our updated i686 Linux SDK which doesn't contain
this path, and may not be needed at all.

This might need further work to be robust, and there's an open PR already
adding -march flags for all supported architectures, but for now we're
playing it safe for 4.2.
Rémi Verschelde 1 年之前
父节点
当前提交
63153c9d36
共有 1 个文件被更改,包括 10 次插入11 次删除
  1. 10 11
      platform/linuxbsd/detect.py

+ 10 - 11
platform/linuxbsd/detect.py

@@ -85,6 +85,16 @@ def configure(env: "Environment"):
         # gdb works fine without it though, so maybe our crash handler could too.
         # gdb works fine without it though, so maybe our crash handler could too.
         env.Append(LINKFLAGS=["-rdynamic"])
         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.
     # CPU architecture flags.
     if env["arch"] == "rv64":
     if env["arch"] == "rv64":
         # G = General-purpose extensions, C = Compression extension (very common).
         # G = General-purpose extensions, C = Compression extension (very common).
@@ -469,22 +479,11 @@ def configure(env: "Environment"):
     if platform.system() == "FreeBSD":
     if platform.system() == "FreeBSD":
         env.Append(LINKFLAGS=["-lkvm"])
         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
     # Link those statically for portability
     if env["use_static_cpp"]:
     if env["use_static_cpp"]:
         env.Append(LINKFLAGS=["-static-libgcc", "-static-libstdc++"])
         env.Append(LINKFLAGS=["-static-libgcc", "-static-libstdc++"])
         if env["use_llvm"] and platform.system() != "FreeBSD":
         if env["use_llvm"] and platform.system() != "FreeBSD":
             env["LINKCOM"] = env["LINKCOM"] + " -l:libatomic.a"
             env["LINKCOM"] = env["LINKCOM"] + " -l:libatomic.a"
-
     else:
     else:
         if env["use_llvm"] and platform.system() != "FreeBSD":
         if env["use_llvm"] and platform.system() != "FreeBSD":
             env.Append(LIBS=["atomic"])
             env.Append(LIBS=["atomic"])