Commit Graph

7 Commits

Author SHA1 Message Date
Rob Mohr
a0ba54f648 Roll GN to 239533d
This caused gn format to flag many things which were also fixed.

Change-Id: Ie1d9081a1b08047bec52c60f54d2a94366be1ba6
2020-02-28 01:33:18 +00:00
Wyatt Hepler
2119240da1 GN build: Override built-in targets
- Override built-in targets, which gives more flexibility than
  set_defaults.
- Provide the default C++ in the toolchain, which can be overridden by
  explicitly specifying a config on a target.
- Remove the C++17 default flags from public configs, since it is no
  longer needed.

Change-Id: If211bada971c46cef83909bf15811a4f2c1eb7fd
2020-01-16 11:41:15 -08:00
Wyatt Hepler
c3a2d475ce Build tweaks for C files
- Use the full file name for object files in the GN build, e.g.
  file.cc.o instead of file.o. This allows having .cc and .c files with
  the same name.
- Have the pw_auto_add_simple_module CMake function build .c and .cc
  test files together.

Change-Id: I3086a96bcc55b013db4f2c278418c17ce1b9fd82
2020-01-09 22:18:49 +00:00
Paul Mathieu
0b955ca0d3 arm_gcc: help ld link all these libs together
There is some confusion as to what the following flags do:

--start-group/--end-group
--[no-]whole-archive

Before explaining them further, the following facts should be
highlighted:

Fact: the linker loads *all* input *.o objects
Fact: a static library is an archive of object files
Fact: the linker will try to resolve symbols across *all* currently
	loaded object
Fact: if a symbol cannot be resolved among currently loaded object, the
	linker will consider static libraries in the order provided and
	load the first object that provides that symbol
Fact: the linker only considers static libraries once and in the order
	provided

--start-group/--end-group pairs tell the linker to re-attempt
considering the libraries contained within the pair, and *in the order
provded* for as long as new unresolved symbols can be resolved that way.

--whole-archive/--no-whole-archive pairs tell the linker to load all
objects from the libraries contained within the pair, making it
equivalent to manually extracting all the object files out of these
libraries and providing them on the command line to the linker

In well-formed cases, none of these flags are necessary. An acyclic
chain of depencies can be established within these libraries by making
them into source_set() targets that depend on each other. In this case,
gn will output the correct order for these libraries.

There are cases where this is not possible. This is typically the case
when vendor-provided libraries have circular dependencies among them.
In these cases, either --start-group/--end-group or
--whole-archive/--no-whole-archive pairs need to be used.

--whole-archive/--no-whole-archive is safer because it allows the proper
resolution of weak/strong symbols.
Example:
libfoo.a:
  foo.o:
    w foo

libbar.a:
  bar.o:
    T foo

main.o:
  U foo

$ gcc main.o libfoo.a libbar.a

will result in the weak symbol defined in libfoo.a to be used.

$ gcc main.o --Wl,--whole-archive libfoo.a libbar.a -wl,--no-whole-archive

will result in the strong symbol defined in libbar.a to be used.

In light of all of the above, we propose always using
--whole-archive/--no-whole-archive and relying on --gc-sections to trim
the resulting executable to a reasonable size.

Change-Id: I355200961b6df6e797f3035f7945eb1a7f9e30b7
2019-12-18 16:43:36 +00:00
Keir Mierle
3db839697b Switch ARM GCC toolchain to use string_join()
This switches the ARM GCC toolchain to use the GN's new string_join()
function to make the long literals in the GCC toolchain files easier to
read.

Change-Id: I7fac49d591a4f589cb11afa41d213adaef411b30
2019-12-17 19:18:07 +00:00
Wyatt Hepler
979890d732 Compiler option updates
- Add -fdiagnostics-color so that compiler warnings are colorized. The
  way Ninja invokes GCC disables colors by default.
- Move -Wno-psabi up to the arm_gcc_toolchain template so that it
  doesn't have to be specified for each arm_gcc_toolchain instance.
- Add -Werror to the strict_warnings config to prevent warnings from
  slipping through. Exempt a few warnings that should actually be
  warnings.

Change-Id: I8656d6690b488f7b004f15abd7100b62e1945cfd
2019-11-07 10:51:32 -08:00
Alexei Frolov
1a82c146ff
Initial Pigweed modules
This change adds Pigweed's first few (incomplete) modules: pw_build,
pw_status, and pw_toolchain. The main scaffolding for Pigweed's GN-based
build system is also included, with a root BUILDCONFIG and BUILD.gn file
defining a top-level modules build target.

Change-Id: I09599443d50696343d6c5b85853cb5cee3ce0026
2019-10-31 17:43:53 -07:00