diff options
author | brettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-11-22 23:30:28 +0000 |
---|---|---|
committer | brettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-11-22 23:30:28 +0000 |
commit | 429d1d87560b14d603f287a1e4006536f82ed59e (patch) | |
tree | 9bc8d9f584cde2fb8343d6aacc354f65c94aa182 /build/config | |
parent | 8ba35c637386a9b5dccb2881137f8bdfeffa3e63 (diff) | |
download | chromium_src-429d1d87560b14d603f287a1e4006536f82ed59e.zip chromium_src-429d1d87560b14d603f287a1e4006536f82ed59e.tar.gz chromium_src-429d1d87560b14d603f287a1e4006536f82ed59e.tar.bz2 |
GN: Add support for 32- and 64-bit cross-compiles.
This makes it possible on Linux to refer to 64-bit targets from a 32-bit build, and 32-bit targets from a 64-bit build.
This also adds flags for Mac cross-compiles but I haven't written the toolchain definitions yet.
BUG=322106
R=scottmg@chromium.org
Review URL: https://codereview.chromium.org/81153003
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@236871 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'build/config')
-rw-r--r-- | build/config/BUILDCONFIG.gn | 32 | ||||
-rw-r--r-- | build/config/compiler/BUILD.gn | 28 |
2 files changed, 45 insertions, 15 deletions
diff --git a/build/config/BUILDCONFIG.gn b/build/config/BUILDCONFIG.gn index f67106b..de1ee08b 100644 --- a/build/config/BUILDCONFIG.gn +++ b/build/config/BUILDCONFIG.gn @@ -383,20 +383,32 @@ set_defaults("source_set") { # default toolchain. if (is_win) { - if (cpu_arch == "x64") { + if (build_cpu_arch == "x64") { host_toolchain = "//build/toolchain/win:64" - } else if (cpu_arch == "x86") { + } else if (build_cpu_arch == "x86") { host_toolchain = "//build/toolchain/win:32" } - set_default_toolchain(host_toolchain) + + if (cpu_arch == "x64") { + set_default_toolchain("//build/toolchain/win:64") + } else if (cpu_arch == "x86") { + set_default_toolchain("//build/toolchain/win:32") + } } else if (is_linux) { - host_toolchain = "//build/toolchain/linux:host" - if (cpu_arch == "arm" && build_cpu_arch != "arm") { - # Special toolchain for ARM cross-compiling. - set_default_toolchain("//build/toolchain/linux:arm-cross-compile") - } else { - # Use whatever GCC is on the current platform. - set_default_toolchain(host_toolchain) + if (build_cpu_arch == "arm") { + host_toolchain = "//build/toolchain/linux:arm" + } else if (build_cpu_arch == "x86") { + host_toolchain = "//build/toolchain/linux:32" + } else if (build_cpu_arch == "x64") { + host_toolchain = "//build/toolchain/linux:64" + } + + if (build_cpu_arch == "arm") { + set_default_toolchain("//build/toolchain/linux:arm") + } else if (build_cpu_arch == "x86") { + set_default_toolchain("//build/toolchain/linux:32") + } else if (build_cpu_arch == "x64") { + set_default_toolchain("//build/toolchain/linux:64") } } else if (is_mac) { host_toolchain = "//build/toolchain/mac:clang" diff --git a/build/config/compiler/BUILD.gn b/build/config/compiler/BUILD.gn index 6f69e05..2ded34e 100644 --- a/build/config/compiler/BUILD.gn +++ b/build/config/compiler/BUILD.gn @@ -39,14 +39,12 @@ config("compiler") { cflags += [ "-fstack-protector", "--param=ssp-buffer-size=4" ] } - # Mac-specific compiler flags setup. - # ---------------------------------- if (is_mac) { + # Mac-specific compiler flags setup. + # ---------------------------------- + # These flags are shared between the C compiler and linker. common_mac_flags = [ - # TODO(brettw) obviously this arch flag needs to be parameterized. - "-arch i386", - # Set which SDK to use. # TODO(brettw) this needs to be configurable somehow. "-isysroot", "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.7.sdk", @@ -54,6 +52,13 @@ config("compiler") { "-mmacosx-version-min=10.6", ] + # CPU architecture. + if (cpu_arch == "x64") { + common_mac_flags += "-arch x86_64" + } else if (cpu_arch == "x32") { + common_mac_flags += "-arch i386" + } + cflags += common_mac_flags + [ # Without this, the constructors and destructors of a C++ object inside # an Objective C struct won't be called, which is very bad. @@ -70,6 +75,19 @@ config("compiler") { "-Wl,-rpath,@loader_path/.", "-Wl,-rpath,@loader_path/../../..", ] + } else { + # Non-Mac Posix compiler flags setup. + # ----------------------------------- + + # CPU architecture. We may or may not be doing a cross compile now, so for + # simplicity we always explicitly set the architecture. + if (cpu_arch == "x64") { + cflags += "-m64" + ldflags += "-m64" + } else if (cpu_arch == "x32") { + cflags += "-m32" + ldflags += "-m32" + } } # Linux-specific compiler flags setup. |