apache / apache/nuttx

Export Make.defs broken, missing HEAD_OBJ, LDENDGROUP, LDSTARTGROUP

Open
#6,082 3 comments 0 reactions 0 assignees View on GitHub
Dominant language
C
Stars
4k
Forks
1.7k
Avg merge
1d 17h
Merged PRs (30d)
237

Description

From the e-mail reported on 2021-07-19

[NuttX export cannot set some variables (i.e. LDSTARTGROUP LDENDGROUP)](https://lists.apache.org/thread/1mh1dpps9v4bt6sq26oxrx2nbn9xrg2s)

I have found cause for broken/empty LDENDGROUP and LDSTARTGROUP in exported Make.defs
```
nuttx-export-10.1.0-RC1/scripts/Make.defs
```
as
```
HEAD_OBJ =
LDENDGROUP =
LDFLAGS = -nostartfiles -nodefaultlibs
LDSTARTGROUP =
```

The reason is that
```
tools/mkexport.sh
```
invokes
```
${MAKE} -C "${TOPDIR}/tools" -f Makefile.export TOPDIR="${TOPDIR}"
```
tools/Makefile.export includes
```
include $(TOPDIR)/.config
include $(EXPORTDIR)/Make.defs
```
and generates temporary `${EXPORTDIR}/makeinfo.sh`

But LDENDGROUP and LDSTARTGROUP are defined in
```
arch/{avr,hc,mips,misoc,or1k,renesas,risc-v,sim,x86,x86_64,xtensa}/src/Makefile
```
which are not sourced by `tools/Makefile.export`.

Only exception is `arch/arm/src/rtl8720c/Toolchain.defs` which could
probably work.

The question is if to try to source complete Makefile by export (probably would lead to other problems) or to change how architectures defines these options for toolchain.

It can take more time to solve this problem clean way. May it be it solves if build system is switched. I would prefer meson + ninja above cmake or stay with GNU make, but cmake support is one of the most robust options today.

As for temporal workaround I suggest to define some flag in each Make.defs setting LD=*-gcc to indicate that
```
LINK_IS_DONE_BY_CC=y
```
Or may it be set it in arch Kconfig then it can be used even during configuration or can be configurable, which would do probably more harm than proffit.

Actual state is that `LDENDGROUP` and `LDSTARTGROUP` must not be used in builds using exported Make.defs directly. Use requires check that they are empty and workaround as has been hacked into [pysimCoder](https://github.com/robertobucher/pysimCoder) NuttX template [nuttx.tmf](https://github.com/robertobucher/pysimCoder/blob/master/CodeGen/templates/nuttx.tmf).

Missing `HEAD_OBJ` is worse because it cannot be guessed easily by the pysimCoder or OMK build which are using NuttX export.

Best wishes,

Pavel

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.