Index: build/toolchain/linux/BUILD.gn |
diff --git a/build/toolchain/linux/BUILD.gn b/build/toolchain/linux/BUILD.gn |
index 016bf29a9507427defa564b8ff40bc846a56c2a6..ffb378beb8814a339572a0948f23be869cc0afde 100644 |
--- a/build/toolchain/linux/BUILD.gn |
+++ b/build/toolchain/linux/BUILD.gn |
@@ -7,116 +7,174 @@ cxx = "g++" |
ar = "ar" |
ld = cxx |
-# Everything up to the toolchain args is an exact copy of the GCC version |
-# below. Keep in sync! Only the compiler variable definitions have changed. |
-toolchain("host") { |
+# The toolchains below all issue the same commands with some different flags. |
+# TODO(brettw) it would be nice to have a different way to express this without |
+# so much duplication. |
+cc_command = "$cc -MMD -MF \$out.d \$defines \$includes \$cflags \$cflags_c -c \$in -o \$out" |
+cxx_command = "$cxx -MMD -MF \$out.d \$defines \$includes \$cflags \$cflags_cc -c \$in -o \$out" |
+alink_command = "rm -f \$out && $ar rcs \$out \$in" |
+solink_command = "if [ ! -e \$lib -o ! -e \${lib}.TOC ]; then $ld -shared \$ldflags -o \$lib -Wl,-soname=\$soname -Wl,--whole-archive \$in \$solibs -Wl,--no-whole-archive \$libs && { readelf -d \${lib} | grep SONAME ; nm -gD -f p \${lib} | cut -f1-2 -d' '; } > \${lib}.TOC; else $ld -shared \$ldflags -o \$lib -Wl,-soname=\$soname -Wl,--whole-archive \$in \$solibs -Wl,--no-whole-archive \$libs && { readelf -d \${lib} | grep SONAME ; nm -gD -f p \${lib} | cut -f1-2 -d' '; } > \${lib}.tmp && if ! cmp -s \${lib}.tmp \${lib}.TOC; then mv \${lib}.tmp \${lib}.TOC ; fi; fi" |
+link_command = "$ld \$ldflags -o \$out -Wl,--start-group \$in \$solibs -Wl,--end-group \$libs" |
+stamp_command = "\${postbuilds}touch \$out" |
+copy_command = "ln -f \$in \$out 2>/dev/null || (rm -rf \$out && cp -af \$in \$out)" |
+ |
+# ARM -------------------------------------------------------------------------- |
+ |
+cc = "arm-linux-gnueabi-gcc" |
+cxx = "arm-linux-gnueabi-g++" |
+ar = "arm-linux-gnueabi-ar" |
+ld = cxx |
+ |
+toolchain("arm") { |
# Make these apply to all tools below. |
lib_prefix = "-l" |
lib_dir_prefix="-L" |
tool("cc") { |
# cflags_pch_c |
- command = "$cc -MMD -MF \$out.d \$defines \$includes \$cflags \$cflags_c -c \$in -o \$out" |
+ command = cc_command |
description = "CC \$out" |
depfile = "\$out.d" |
deps = "gcc" |
} |
tool("cxx") { |
# cflags_pch_cc |
- command = "$cxx -MMD -MF \$out.d \$defines \$includes \$cflags \$cflags_cc -c \$in -o \$out" |
+ command = cxx_command |
description = "CXX \$out" |
depfile = "\$out.d" |
deps = "gcc" |
} |
tool("alink") { |
- command = "rm -f \$out && $ar rcs \$out \$in" |
+ command = alink_command |
description = "AR \$out" |
} |
tool("solink") { |
- command = "if [ ! -e \$lib -o ! -e \${lib}.TOC ]; then $ld -shared \$ldflags -o \$lib -Wl,-soname=\$soname -Wl,--whole-archive \$in \$solibs -Wl,--no-whole-archive \$libs && { readelf -d \${lib} | grep SONAME ; nm -gD -f p \${lib} | cut -f1-2 -d' '; } > \${lib}.TOC; else $ld -shared \$ldflags -o \$lib -Wl,-soname=\$soname -Wl,--whole-archive \$in \$solibs -Wl,--no-whole-archive \$libs && { readelf -d \${lib} | grep SONAME ; nm -gD -f p \${lib} | cut -f1-2 -d' '; } > \${lib}.tmp && if ! cmp -s \${lib}.tmp \${lib}.TOC; then mv \${lib}.tmp \${lib}.TOC ; fi; fi" |
+ command = solink_command |
description = "SOLINK \$lib" |
#pool = "link_pool" |
restat = "1" |
} |
tool("link") { |
- command = "$ld \$ldflags -o \$out -Wl,--start-group \$in \$solibs -Wl,--end-group \$libs" |
+ command = link_command |
description = "LINK \$out" |
#pool = "link_pool" |
} |
tool("stamp") { |
- command = "\${postbuilds}touch \$out" |
+ command = stamp_command |
description = "STAMP \$out" |
} |
tool("copy") { |
- command = "ln -f \$in \$out 2>/dev/null || (rm -rf \$out && cp -af \$in \$out)" |
+ command = copy_command |
description = "COPY \$in \$out" |
} |
# When invoking this toolchain not as the default one, these args will be |
# passed to the build. They are ignored when this is the default toolchain. |
toolchain_args() { |
- # Pass the current CPU architecture to the build as the toolchain to use. |
- # If the default toolchain is set to ARM and the local system is x86, this |
- # will make this secondary toolchain refer to the host GCC again. |
- cpu_arch = build_cpu_arch |
+ cpu_arch = "arm" |
} |
} |
-# ARM Cross-Compile ------------------------------------------------------------ |
+# 32-bit ----------------------------------------------------------------------- |
-cc = "arm-linux-gnueabi-gcc" |
-cxx = "arm-linux-gnueabi-g++" |
-ar = "arm-linux-gnueabi-ar" |
-ld = cxx |
+toolchain("32") { |
+ # Make these apply to all tools below. |
+ lib_prefix = "-l" |
+ lib_dir_prefix="-L" |
+ |
+ tool("cc") { |
+ # cflags_pch_c |
+ command = cc_command |
+ description = "CC \$out" |
+ depfile = "\$out.d" |
+ deps = "gcc" |
+ } |
+ tool("cxx") { |
+ # cflags_pch_cc |
+ command = cxx_command |
+ description = "CXX \$out" |
+ depfile = "\$out.d" |
+ deps = "gcc" |
+ } |
+ tool("alink") { |
+ command = alink_command |
+ description = "AR \$out" |
+ } |
+ tool("solink") { |
+ command = solink_command |
+ description = "SOLINK \$lib" |
+ #pool = "link_pool" |
+ restat = "1" |
+ } |
+ tool("link") { |
+ command = link_command |
+ description = "LINK \$out" |
+ #pool = "link_pool" |
+ } |
+ tool("stamp") { |
+ command = stamp_command |
+ description = "STAMP \$out" |
+ } |
+ tool("copy") { |
+ command = copy_command |
+ description = "COPY \$in \$out" |
+ } |
-# Everything up the the toolchain args is an exact copy of the GCC version |
-# below. Keep in sync! Only the compiler variable definitions have changed. |
-toolchain("arm-cross-compile") { |
+ # When invoking this toolchain not as the default one, these args will be |
+ # passed to the build. They are ignored when this is the default toolchain. |
+ toolchain_args() { |
+ cpu_arch = "x32" |
+ } |
+} |
+ |
+# 64-bit ----------------------------------------------------------------------- |
+ |
+toolchain("64") { |
# Make these apply to all tools below. |
lib_prefix = "-l" |
lib_dir_prefix="-L" |
tool("cc") { |
# cflags_pch_c |
- command = "$cc -MMD -MF \$out.d \$defines \$includes \$cflags \$cflags_c -c \$in -o \$out" |
+ command = cc_command |
description = "CC \$out" |
depfile = "\$out.d" |
deps = "gcc" |
} |
tool("cxx") { |
# cflags_pch_cc |
- command = "$cxx -MMD -MF \$out.d \$defines \$includes \$cflags \$cflags_cc -c \$in -o \$out" |
+ command = cxx_command |
description = "CXX \$out" |
depfile = "\$out.d" |
deps = "gcc" |
} |
tool("alink") { |
- command = "rm -f \$out && $ar rcs \$out \$in" |
+ command = alink_command |
description = "AR \$out" |
} |
tool("solink") { |
- command = "if [ ! -e \$lib -o ! -e \${lib}.TOC ]; then $ld -shared \$ldflags -o \$lib -Wl,-soname=\$soname -Wl,--whole-archive \$in \$solibs -Wl,--no-whole-archive \$libs && { readelf -d \${lib} | grep SONAME ; nm -gD -f p \${lib} | cut -f1-2 -d' '; } > \${lib}.TOC; else $ld -shared \$ldflags -o \$lib -Wl,-soname=\$soname -Wl,--whole-archive \$in \$solibs -Wl,--no-whole-archive \$libs && { readelf -d \${lib} | grep SONAME ; nm -gD -f p \${lib} | cut -f1-2 -d' '; } > \${lib}.tmp && if ! cmp -s \${lib}.tmp \${lib}.TOC; then mv \${lib}.tmp \${lib}.TOC ; fi; fi" |
+ command = solink_command |
description = "SOLINK \$lib" |
#pool = "link_pool" |
restat = "1" |
} |
tool("link") { |
- command = "$ld \$ldflags -o \$out -Wl,--start-group \$in \$solibs -Wl,--end-group \$libs" |
+ command = link_command |
description = "LINK \$out" |
#pool = "link_pool" |
} |
tool("stamp") { |
- command = "\${postbuilds}touch \$out" |
+ command = stamp_command |
description = "STAMP \$out" |
} |
tool("copy") { |
- command = "ln -f \$in \$out 2>/dev/null || (rm -rf \$out && cp -af \$in \$out)" |
+ command = copy_command |
description = "COPY \$in \$out" |
} |
# When invoking this toolchain not as the default one, these args will be |
# passed to the build. They are ignored when this is the default toolchain. |
toolchain_args() { |
- cpu_arch = "arm" |
+ cpu_arch = "x64" |
} |
} |