OLD | NEW |
---|---|
1 # Copyright 2016 The Chromium Authors. All rights reserved. | 1 # Copyright 2016 The Chromium Authors. All rights reserved. |
2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
4 | 4 |
5 # Define the sysroot directory. | |
6 sysroot = "$root_out_dir/sysroot" | |
7 | |
5 config("fusl_config") { | 8 config("fusl_config") { |
6 cflags = [ | 9 cflags = [ |
7 # Flags from musl | 10 # Flags from musl |
8 "-std=c99", | 11 "-std=c99", |
9 "-ffreestanding", | 12 "-ffreestanding", |
10 "-nostdinc", | 13 "-nostdinc", |
11 | 14 |
12 "-D_XOPEN_SOURCE=700", | 15 "-D_XOPEN_SOURCE=700", |
13 | 16 |
14 "-Wa,--noexecstack", | 17 "-Wa,--noexecstack", |
(...skipping 1445 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1460 "src/unistd/unlinkat.c", | 1463 "src/unistd/unlinkat.c", |
1461 "src/unistd/usleep.c", | 1464 "src/unistd/usleep.c", |
1462 "src/unistd/write.c", | 1465 "src/unistd/write.c", |
1463 "src/unistd/writev.c", | 1466 "src/unistd/writev.c", |
1464 ] | 1467 ] |
1465 | 1468 |
1466 # Arch specific sources. | 1469 # Arch specific sources. |
1467 deps += [ ":libc_${current_cpu}" ] | 1470 deps += [ ":libc_${current_cpu}" ] |
1468 } | 1471 } |
1469 | 1472 |
1470 # Build a sysroot. | 1473 static_library("libm") { |
1471 sysroot = "${target_out_dir}/sysroot/" | 1474 complete_static_lib = true |
1472 sysroot_lib_dir = "${sysroot}/usr/lib" | 1475 } |
1473 sysroot_include_dir = "${sysroot}/usr/include" | |
1474 | 1476 |
1475 template("copy_objects") { | 1477 template("copy_objects") { |
1476 assert(defined(invoker.input_dir), "input_dir must be defined") | 1478 assert(defined(invoker.input_dir), "input_dir must be defined") |
1477 assert(defined(invoker.output_dir), "output_dir must be defined") | 1479 assert(defined(invoker.output_dir), "output_dir must be defined") |
1478 object_prefix = "" | 1480 object_prefix = "" |
1479 if (defined(invoker.object_prefix)) { | 1481 if (defined(invoker.object_prefix)) { |
1480 object_prefix = invoker.object_prefix | 1482 object_prefix = invoker.object_prefix |
1481 } | 1483 } |
1482 foreach(file, invoker.sources) { | 1484 foreach(file, invoker.sources) { |
1483 copy("copy_${file}") { | 1485 copy("copy_${file}") { |
(...skipping 13 matching lines...) Expand all Loading... | |
1497 group(target_name) { | 1499 group(target_name) { |
1498 deps = [ | 1500 deps = [ |
1499 ":crt", | 1501 ":crt", |
1500 ] | 1502 ] |
1501 foreach(file, invoker.sources) { | 1503 foreach(file, invoker.sources) { |
1502 deps += [ ":copy_$file" ] | 1504 deps += [ ":copy_$file" ] |
1503 } | 1505 } |
1504 } | 1506 } |
1505 } | 1507 } |
1506 | 1508 |
1509 sysroot_lib_dir = "${sysroot}/usr/lib" | |
1510 sysroot_include_dir = "${sysroot}/usr/include" | |
1511 | |
1507 copy_objects("copy_crt_objects") { | 1512 copy_objects("copy_crt_objects") { |
1508 sources = [ | 1513 sources = [ |
1509 "Scrt1.o", | 1514 "Scrt1.o", |
1510 "crt1.o", | 1515 "crt1.o", |
1511 "rcrt1.o", | 1516 "rcrt1.o", |
1512 ] | 1517 ] |
1513 object_prefix = "crt." | 1518 object_prefix = "crt." |
1514 input_dir = "crt" | 1519 input_dir = "crt" |
1515 output_dir = "${sysroot_lib_dir}" | 1520 output_dir = "${sysroot_lib_dir}" |
1516 } | 1521 } |
(...skipping 24 matching lines...) Expand all Loading... | |
1541 if (current_cpu == "x64") { | 1546 if (current_cpu == "x64") { |
1542 sources = [ | 1547 sources = [ |
1543 "arch/x86_64/bits", | 1548 "arch/x86_64/bits", |
1544 ] | 1549 ] |
1545 } | 1550 } |
1546 outputs = [ | 1551 outputs = [ |
1547 "${sysroot_include_dir}/{{source_name_part}}", | 1552 "${sysroot_include_dir}/{{source_name_part}}", |
1548 ] | 1553 ] |
1549 } | 1554 } |
1550 | 1555 |
1551 copy("copy_libc") { | 1556 copy("copy_libs") { |
1552 deps = [ | 1557 deps = [ |
1553 ":libc", | 1558 ":libc", |
1559 ":libm", | |
1554 ] | 1560 ] |
1555 sources = [ | 1561 sources = [ |
1556 "${target_out_dir}/libc.a", | 1562 "${target_out_dir}/libc.a", |
1563 "${target_out_dir}/libm.a", | |
1557 ] | 1564 ] |
1558 outputs = [ | 1565 outputs = [ |
1559 "${sysroot_lib_dir}/libc.a", | 1566 "${sysroot_lib_dir}/{{source_name_part}}.a", |
1560 ] | 1567 ] |
1561 } | 1568 } |
1562 | 1569 |
1563 group("sysroot") { | 1570 group("copy_sysroot") { |
1564 deps = [ | 1571 deps = [ |
1565 ":copy_crt_objects", | 1572 ":copy_crt_objects", |
1566 ":copy_include", | 1573 ":copy_include", |
1567 ":copy_include_bits", | 1574 ":copy_include_bits", |
1568 ":copy_libc", | 1575 ":copy_libs", |
1569 ] | 1576 ] |
1570 if (current_cpu == "x64") { | 1577 if (current_cpu == "x64") { |
1571 deps += [ ":copy_crt_x64_objects" ] | 1578 deps += [ ":copy_crt_x64_objects" ] |
1572 } | 1579 } |
1573 } | 1580 } |
1574 | 1581 |
1575 group("fusl") { | 1582 # Everything that is using the fusl sysroot has a build time |
1583 # dependency against it. However, taking an explicit dependency | |
1584 # against it will cause crt1.o and friends to be explicitly linked | |
1585 # in. This is problematic, as linkers will already by default link in | |
1586 # the correct bits of the C runtime. By adding this no-op action, we | |
1587 # preserve all the build time dependencies, but prevent crt1.o | |
1588 # 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
| |
1589 action("sysroot") { | |
1576 deps = [ | 1590 deps = [ |
1577 ":crt", | 1591 ":copy_sysroot", |
1578 ":libc", | 1592 ] |
1593 | |
1594 script = "tools/sysroot_nothing.py" | |
1595 | |
1596 stamp = "$target_gen_dir/sysroot_nothing.stamp" | |
1597 | |
1598 args = [ rebase_path(stamp) ] | |
1599 | |
1600 outputs = [ | |
1601 stamp, | |
1602 ] | |
1603 } | |
1604 | |
1605 config("sysroot_config") { | |
1606 rebased_sysroot = rebase_path(sysroot) | |
1607 | |
1608 cflags = [ | |
1609 "--sysroot=$rebased_sysroot", | |
1610 "-fPIC", | |
1611 "-static", | |
1612 ] | |
1613 | |
1614 ldflags = [ "--sysroot=$rebased_sysroot" ] | |
1615 } | |
1616 | |
1617 executable("empty_main") { | |
1618 configs = [] | |
1619 configs += [ ":sysroot_config" ] | |
1620 | |
1621 sources = [ | |
1622 "test/empty_main.c", | |
1623 ] | |
1624 | |
1625 deps = [ | |
1579 ":sysroot", | 1626 ":sysroot", |
1580 ] | 1627 ] |
1581 } | 1628 } |
1629 | |
1630 group("fusl") { | |
1631 deps = [ | |
1632 ":crt(//build/toolchain/fusl:fusl_$current_cpu)", | |
1633 ":empty_main(//build/toolchain/fusl:fusl_$current_cpu)", | |
1634 ":libc(//build/toolchain/fusl:fusl_$current_cpu)", | |
1635 ":sysroot(//build/toolchain/fusl:fusl_$current_cpu)", | |
1636 ] | |
1637 } | |
OLD | NEW |