Index: fusl/BUILD.gn |
diff --git a/fusl/BUILD.gn b/fusl/BUILD.gn |
index a352bcbc19e88b8e6c358b7889dbe09ab84f0390..a77d3bc05049683190cbe9cc81646f625315d8c7 100644 |
--- a/fusl/BUILD.gn |
+++ b/fusl/BUILD.gn |
@@ -2,6 +2,9 @@ |
# Use of this source code is governed by a BSD-style license that can be |
# found in the LICENSE file. |
+# Define the sysroot directory. |
+sysroot = "$root_out_dir/sysroot" |
+ |
config("fusl_config") { |
cflags = [ |
# Flags from musl |
@@ -1467,10 +1470,9 @@ static_library("libc") { |
deps += [ ":libc_${current_cpu}" ] |
} |
-# Build a sysroot. |
-sysroot = "${target_out_dir}/sysroot/" |
-sysroot_lib_dir = "${sysroot}/usr/lib" |
-sysroot_include_dir = "${sysroot}/usr/include" |
+static_library("libm") { |
+ complete_static_lib = true |
+} |
template("copy_objects") { |
assert(defined(invoker.input_dir), "input_dir must be defined") |
@@ -1504,6 +1506,9 @@ template("copy_objects") { |
} |
} |
+sysroot_lib_dir = "${sysroot}/usr/lib" |
+sysroot_include_dir = "${sysroot}/usr/include" |
+ |
copy_objects("copy_crt_objects") { |
sources = [ |
"Scrt1.o", |
@@ -1548,34 +1553,85 @@ copy("copy_include_bits") { |
] |
} |
-copy("copy_libc") { |
+copy("copy_libs") { |
deps = [ |
":libc", |
+ ":libm", |
] |
sources = [ |
"${target_out_dir}/libc.a", |
+ "${target_out_dir}/libm.a", |
] |
outputs = [ |
- "${sysroot_lib_dir}/libc.a", |
+ "${sysroot_lib_dir}/{{source_name_part}}.a", |
] |
} |
-group("sysroot") { |
+group("copy_sysroot") { |
deps = [ |
":copy_crt_objects", |
":copy_include", |
":copy_include_bits", |
- ":copy_libc", |
+ ":copy_libs", |
] |
if (current_cpu == "x64") { |
deps += [ ":copy_crt_x64_objects" ] |
} |
} |
-group("fusl") { |
+# Everything that is using the fusl sysroot has a build time |
+# dependency against it. However, taking an explicit dependency |
+# against it will cause crt1.o and friends to be explicitly linked |
+# in. This is problematic, as linkers will already by default link in |
+# the correct bits of the C runtime. By adding this no-op action, we |
+# preserve all the build time dependencies, but prevent crt1.o |
+# etc. from ending up in downstream targets' linker response files. |
Petr Hosek
2016/01/30 00:02:56
That's what data_deps is for, no need for Python s
kulakowski
2016/01/30 00:04:45
There was some discussion in the mojo irc about th
|
+action("sysroot") { |
+ deps = [ |
+ ":copy_sysroot", |
+ ] |
+ |
+ script = "tools/sysroot_nothing.py" |
+ |
+ stamp = "$target_gen_dir/sysroot_nothing.stamp" |
+ |
+ args = [ rebase_path(stamp) ] |
+ |
+ outputs = [ |
+ stamp, |
+ ] |
+} |
+ |
+config("sysroot_config") { |
+ rebased_sysroot = rebase_path(sysroot) |
+ |
+ cflags = [ |
+ "--sysroot=$rebased_sysroot", |
+ "-fPIC", |
+ "-static", |
+ ] |
+ |
+ ldflags = [ "--sysroot=$rebased_sysroot" ] |
+} |
+ |
+executable("empty_main") { |
+ configs = [] |
+ configs += [ ":sysroot_config" ] |
+ |
+ sources = [ |
+ "test/empty_main.c", |
+ ] |
+ |
deps = [ |
- ":crt", |
- ":libc", |
":sysroot", |
] |
} |
+ |
+group("fusl") { |
+ deps = [ |
+ ":crt(//build/toolchain/fusl:fusl_$current_cpu)", |
+ ":empty_main(//build/toolchain/fusl:fusl_$current_cpu)", |
+ ":libc(//build/toolchain/fusl:fusl_$current_cpu)", |
+ ":sysroot(//build/toolchain/fusl:fusl_$current_cpu)", |
+ ] |
+} |