Skip to content

Commit

Permalink
sys/arduino: work around llvm-ar bug.
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
jcarrano committed Sep 10, 2019
1 parent d9132ee commit 72f934f
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
2 changes: 1 addition & 1 deletion sys/arduino/Makefile.include
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

# Define application sketches module, it will be generated into $(BINDIR)
SKETCH_MODULE ?= arduino_sketches
SKETCH_MODULE_DIR ?= $(BINDIR)/$(SKETCH_MODULE)
SKETCH_MODULE_DIR ?= $(BINDIR)/$(SKETCH_MODULE)_src
SKETCHES = $(wildcard $(APPDIR)/*.sketch)
include $(RIOTBASE)/sys/arduino/sketches.inc.mk

Expand Down
3 changes: 2 additions & 1 deletion sys/arduino/sketches.inc.mk
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ SKETCH_GENERATED_FILES = $(SKETCH_MODULE_DIR)/Makefile $(SKETCH_MODULE_DIR)/$(SK
# Building the module files
# Do not use $^ in receipes as Makefile is also a prerequisite
$(SKETCH_MODULE_DIR)/Makefile: $(SKETCH_MODULE_DIR)/$(SKETCH_CPP)
$(Q)echo 'SRCXX = $(SKETCH_CPP)' > $@
$(Q)echo 'MODULE = $(SKETCH_MODULE)' > $@
$(Q)echo 'SRCXX = $(SKETCH_CPP)' >> $@
$(Q)echo 'include $$(RIOTBASE)/Makefile.base' >> $@
$(SKETCH_MODULE_DIR)/$(SKETCH_CPP): $(SKETCHES_ALL)
@mkdir -p $(@D)
Expand Down

0 comments on commit 72f934f

Please sign in to comment.