[riot-commits] [RIOT-OS/RIOT] 24ddf2: Makefile.base: use thin static archives.

benpicco noreply at github.com
Sun Sep 15 13:04:28 CEST 2019


  Branch: refs/heads/master
  Home:   https://github.com/RIOT-OS/RIOT
  Commit: 24ddf285d228adf1fdfdbf0115a31625a84ad5fd
      https://github.com/RIOT-OS/RIOT/commit/24ddf285d228adf1fdfdbf0115a31625a84ad5fd
  Author: Juan Carrano <j.carrano at fu-berlin.de>
  Date:   2019-09-10 (Tue, 10 Sep 2019)

  Changed paths:
    M Makefile.base
    M makefiles/cflags.inc.mk

  Log Message:
  -----------
  Makefile.base: use thin static archives.

Normal, or thick archives contain a copy of the object code. Thin
archives, on the contrary, are just an index to the .o files.

This patch does two things:

1. Change ARFLAGS to enable the "T" options.
2. Call AR with all relative paths.

The second step is necessary because the build system handles all
absolute paths. If the index in the thin archive contains absolute
paths, archives created in docker are no usable outside, and moving
the objects breaks the archive.

If all arguments to AR are relative, the resulting archive contains
filenames *relative to the .a file* and nothing should break as long
as the relative location of the .a and .o remains unchanged.

Compilation time is unchanged, but disc usage is reduced by approximately
50%. These are the result of a full RIOT build:

| Thin Archive   |  no     |  yes  | Savings (%) |
| -------------- | ------: | ----: | ----------- |
| pkg (10e6 KiB) | 1 790   | 905   | 49%         |
| Non pkg        |    71   |  71   | 1%          |
| Total          | 1 812   | 976   | 46 %        |


  Commit: d9132eec90e23891c7143139107aeec1a78d2d72
      https://github.com/RIOT-OS/RIOT/commit/d9132eec90e23891c7143139107aeec1a78d2d72
  Author: Juan Carrano <j.carrano at fu-berlin.de>
  Date:   2019-09-10 (Tue, 10 Sep 2019)

  Changed paths:
    M Makefile.include
    M makefiles/docker.inc.mk

  Log Message:
  -----------
  Makefile.include: add rule to verify thin archives.

This adds a new target "archive-check".

Thin archives should be created with relative paths so that archives created
in a build container are useful in the host. This check ensures there are no
absolute paths inside thin archives.


  Commit: 72f934f13d6d50d5f2793f42842f410f5c08d277
      https://github.com/RIOT-OS/RIOT/commit/72f934f13d6d50d5f2793f42842f410f5c08d277
  Author: Juan Carrano <j.carrano at fu-berlin.de>
  Date:   2019-09-10 (Tue, 10 Sep 2019)

  Changed paths:
    M sys/arduino/Makefile.include
    M sys/arduino/sketches.inc.mk

  Log Message:
  -----------
  sys/arduino: work around llvm-ar bug.

llvm-ar behaves weidly when creating thin archive. This only manifests
itself when using arduino sketches as these are built from the "bin"
directory.

Specifically, given a directory "m" and an object in "m/obj.o " an
invocation with CWD==m:

```
llvm-ar rcTs ../m.a obj.o
```

Will create a maformed archive. Binutils does not have any issue with this.

The following command, executed with CWD==m/.. works:

```
llvm-ar rcTs m.a m/obj.o
```

The trick used in this commit is to put the source files in a different
directory than the object files and compile from there.


  Commit: 65b71026088f5c2ef7b99fab1e00ca5779f83127
      https://github.com/RIOT-OS/RIOT/commit/65b71026088f5c2ef7b99fab1e00ca5779f83127
  Author: benpicco <benpicco at googlemail.com>
  Date:   2019-09-15 (Sun, 15 Sep 2019)

  Changed paths:
    M Makefile.base
    M Makefile.include
    M makefiles/cflags.inc.mk
    M makefiles/docker.inc.mk
    M sys/arduino/Makefile.include
    M sys/arduino/sketches.inc.mk

  Log Message:
  -----------
  Merge pull request #10195 from jcarrano/thin-archives

Makefile.base: use thin static archives.


Compare: https://github.com/RIOT-OS/RIOT/compare/95a2081cfa61...65b71026088f


More information about the commits mailing list