Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deleted or non selected source files are linked in #16942

Closed
fjmolinas opened this issue Oct 4, 2021 · 2 comments
Closed

Deleted or non selected source files are linked in #16942

fjmolinas opened this issue Oct 4, 2021 · 2 comments
Assignees
Labels
Area: build system Area: Build system Type: bug The issue reports a bug / The PR fixes a bug (including spelling errors)

Comments

@fjmolinas
Copy link
Contributor

fjmolinas commented Oct 4, 2021

Description

This might also occur in other cases but for example when a MODULE has different implementations which are selected vía a PSEUDOMODULE or when SRC file selection changes the old files are still linked in which leads to either bloated code to compilation errors. This was introduced with #14754 where object files started to be linked instead on relying on archives, archives were always recreated so this was not an issue before #14754

RIOT/Makefile.base

Lines 95 to 98 in c1ad435

$(BINDIR)/$(MODULE).a: $(OBJ) | $(DIRS:%=ALL--%)
@# Recreate archive to cleanup deleted/non selected source files objects
$(Q)$(RM) $@
$(Q)cd $(@D) && $(AR) $(ARFLAGS) $(@F) $(subst $(@D)/,,$^)

Steps to reproduce the issue

This can be done in any case where SRC or PSEUDOMODULES are selected/deselected. An example that worked at the time of #14754:

make -C tests/pkg_openwsn/ all -j7
SEMODULE=openwsn_sctimer_ztimer make -C tests/pkg_openwsn/ all -j7

Expected results

Only new files are linked in.

Actual results

Old and new files are linked in.

/home/francisco/opt/gcc-arm-none-eabi-10-2020-q4-major/bin/../lib/gcc/arm-none-eabi/10.2.1/../../../../arm-none-eabi/bin/ld: /home/francisco/workspace/RIOT/tests/pkg_openwsn/bin/iotlab-m3/openwsn/sctimer_ztimer.o: in function `sctimer_init':
/home/francisco/workspace/RIOT/pkg/openwsn/contrib/sctimer_ztimer.c:80: multiple definition of `sctimer_init'; /home/francisco/workspace/RIOT/tests/pkg_openwsn/bin/iotlab-m3/openwsn/sctimer_rtt.o:/home/francisco/workspace/RIOT/pkg/openwsn/contrib/sctimer_rtt.c:84: first defined here
/home/francisco/opt/gcc-arm-none-eabi-10-2020-q4-major/bin/../lib/gcc/arm-none-eabi/10.2.1/../../../../arm-none-eabi/bin/ld: /home/francisco/workspace/RIOT/tests/pkg_openwsn/bin/iotlab-m3/openwsn/sctimer_ztimer.o: in function `sctimer_set_callback':
/home/francisco/workspace/RIOT/pkg/openwsn/contrib/sctimer_ztimer.c:116: multiple definition of `sctimer_set_callback'; /home/francisco/workspace/RIOT/tests/pkg_openwsn/bin/iotlab-m3/openwsn/sctimer_rtt.o:/home/francisco/workspace/RIOT/pkg/openwsn/contrib/sctimer_rtt.c:95: first defined here
/home/francisco/opt/gcc-arm-none-eabi-10-2020-q4-major/bin/../lib/gcc/arm-none-eabi/10.2.1/../../../../arm-none-eabi/bin/ld: /home/francisco/workspace/RIOT/tests/pkg_openwsn/bin/iotlab-m3/openwsn/sctimer_ztimer.o: in function `sctimer_setCompare':
/home/francisco/workspace/RIOT/pkg/openwsn/contrib/sctimer_ztimer.c:120: multiple definition of `sctimer_setCompare'; /home/francisco/workspace/RIOT/tests/pkg_openwsn/bin/iotlab-m3/openwsn/sctimer_rtt.o:/home/francisco/workspace/RIOT/pkg/openwsn/contrib/sctimer_rtt.c:119: first defined here
/home/francisco/opt/gcc-arm-none-eabi-10-2020-q4-major/bin/../lib/gcc/arm-none-eabi/10.2.1/../../../../arm-none-eabi/bin/ld: /home/francisco/workspace/RIOT/tests/pkg_openwsn/bin/iotlab-m3/openwsn/sctimer_ztimer.o: in function `sctimer_readCounter':
/home/francisco/workspace/RIOT/pkg/openwsn/contrib/sctimer_ztimer.c:149: multiple definition of `sctimer_readCounter'; /home/francisco/workspace/RIOT/tests/pkg_openwsn/bin/iotlab-m3/openwsn/sctimer_rtt.o:/home/francisco/workspace/RIOT/pkg/openwsn/contrib/sctimer_rtt.c:150: first defined here
/home/francisco/opt/gcc-arm-none-eabi-10-2020-q4-major/bin/../lib/gcc/arm-none-eabi/10.2.1/../../../../arm-none-eabi/bin/ld: /home/francisco/workspace/RIOT/tests/pkg_openwsn/bin/iotlab-m3/openwsn/sctimer_ztimer.o: in function `sctimer_enable':
/home/francisco/workspace/RIOT/pkg/openwsn/contrib/sctimer_ztimer.c:158: multiple definition of `sctimer_enable'; /home/francisco/workspace/RIOT/tests/pkg_openwsn/bin/iotlab-m3/openwsn/sctimer_rtt.o:/home/francisco/workspace/RIOT/pkg/openwsn/contrib/sctimer_rtt.c:163: first defined here
/home/francisco/opt/gcc-arm-none-eabi-10-2020-q4-major/bin/../lib/gcc/arm-none-eabi/10.2.1/../../../../arm-none-eabi/bin/ld: /home/francisco/workspace/RIOT/tests/pkg_openwsn/bin/iotlab-m3/openwsn/sctimer_ztimer.o: in function `sctimer_disable':
sctimer_ztimer.c:(.text.sctimer_disable+0x0): multiple definition of `sctimer_disable'; /home/francisco/workspace/RIOT/tests/pkg_openwsn/bin/iotlab-m3/openwsn/sctimer_rtt.o:/home/francisco/workspace/RIOT/pkg/openwsn/contrib/sctimer_rtt.c:168: first defined here
collect2: error: ld returned 1 exit status
make: *** [/home/francisco/workspace/RIOT/tests/pkg_openwsn/../../Makefile.include:585: /home/francisco/workspace/RIOT/tests/pkg_openwsn/bin/iotlab-m3/tests_pkg_openwsn.elf] Error 1

Versions

2021.10

@fjmolinas
Copy link
Contributor Author

Note that of course clean fixes the issue but IMO that should not be needed.

@fjmolinas fjmolinas added the Type: bug The issue reports a bug / The PR fixes a bug (including spelling errors) label Oct 4, 2021
@fjmolinas fjmolinas changed the title Deleter or non selected source files are linked in Deleted or non selected source files are linked in Oct 4, 2021
@fjmolinas
Copy link
Contributor Author

Fixed by #16945

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: build system Area: Build system Type: bug The issue reports a bug / The PR fixes a bug (including spelling errors)
Projects
None yet
Development

No branches or pull requests

4 participants