diff mbox series

tools: always create $STAGING_DIR/usr/{include,lib}

Message ID 20200820060637.533293-1-a.heider@gmail.com
State Accepted
Delegated to: Petr Štetiar
Headers show
Series tools: always create $STAGING_DIR/usr/{include,lib} | expand

Commit Message

Andre Heider Aug. 20, 2020, 6:06 a.m. UTC
rules.mk always passes these as -I/-L to the toolchain.

Fixes rare errors like:
cc1: error: staging_dir/target-aarch64_cortex-a53_musl/usr/include: No such file or directory [-Werror=missing-include-dirs]

Signed-off-by: Andre Heider <a.heider@gmail.com>
---
 tools/Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Paul Spooren Aug. 24, 2020, 2:59 a.m. UTC | #1
On 19.08.20 20:06, Andre Heider wrote:
> rules.mk always passes these as -I/-L to the toolchain.
>
> Fixes rare errors like:
> cc1: error: staging_dir/target-aarch64_cortex-a53_musl/usr/include: No such file or directory [-Werror=missing-include-dirs]
>
> Signed-off-by: Andre Heider <a.heider@gmail.com>

Acked-by: Paul Spooren <mail@aparcar.org>

> ---
>   tools/Makefile | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/tools/Makefile b/tools/Makefile
> index f038c90ba9..325c0995ee 100644
> --- a/tools/Makefile
> +++ b/tools/Makefile
> @@ -123,7 +123,7 @@ define PrepareStaging
>   		$(if $(QUIET),,set -x;) \
>   		mkdir -p "$$dir"; \
>   		cd "$$dir"; \
> -		mkdir -p bin lib stamp; \
> +		mkdir -p bin lib stamp usr/include usr/lib; \
>   	); done
>   endef
Rosen Penev Aug. 24, 2020, 3:21 a.m. UTC | #2
On Sun, Aug 23, 2020 at 8:02 PM Paul Spooren <mail@aparcar.org> wrote:
>
> On 19.08.20 20:06, Andre Heider wrote:
> > rules.mk always passes these as -I/-L to the toolchain.
> >
> > Fixes rare errors like:
> > cc1: error: staging_dir/target-aarch64_cortex-a53_musl/usr/include: No such file or directory [-Werror=missing-include-dirs]
> >
> > Signed-off-by: Andre Heider <a.heider@gmail.com>
>
> Acked-by: Paul Spooren <mail@aparcar.org>
Acked-by: Rosen Penev <rosenp@gmail.com>

I've constantly had this issue. I never investigated why.
>
> > ---
> >   tools/Makefile | 2 +-
> >   1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/tools/Makefile b/tools/Makefile
> > index f038c90ba9..325c0995ee 100644
> > --- a/tools/Makefile
> > +++ b/tools/Makefile
> > @@ -123,7 +123,7 @@ define PrepareStaging
> >               $(if $(QUIET),,set -x;) \
> >               mkdir -p "$$dir"; \
> >               cd "$$dir"; \
> > -             mkdir -p bin lib stamp; \
> > +             mkdir -p bin lib stamp usr/include usr/lib; \
> >       ); done
> >   endef
>
> _______________________________________________
> openwrt-devel mailing list
> openwrt-devel@lists.openwrt.org
> https://lists.openwrt.org/mailman/listinfo/openwrt-devel
Jo-Philipp Wich Aug. 24, 2020, 10:55 a.m. UTC | #3
Hi,

> rules.mk always passes these as -I/-L to the toolchain.
> 
> Fixes rare errors like:
> cc1: error: staging_dir/target-aarch64_cortex-a53_musl/usr/include: No such file or directory [-Werror=missing-include-dirs]
> 
> Signed-off-by: Andre Heider <a.heider@gmail.com>

NAK - I'd prefer if we remove the faulty/redundant/unused include paths
from rules.mk instead.

~ Jo
Paul Spooren Aug. 24, 2020, 5:56 p.m. UTC | #4
On 24.08.20 00:55, Jo-Philipp Wich wrote:
> Hi,
>
>> rules.mk always passes these as -I/-L to the toolchain.
>>
>> Fixes rare errors like:
>> cc1: error: staging_dir/target-aarch64_cortex-a53_musl/usr/include: No such file or directory [-Werror=missing-include-dirs]
>>
>> Signed-off-by: Andre Heider <a.heider@gmail.com>
> NAK - I'd prefer if we remove the faulty/redundant/unused include paths
> from rules.mk instead.

Isn't that breaking some packages which currently use `/usr/lib`?

packages.git/boost:
https://github.com/openwrt/packages/blob/e2e152da599ceeacf06b4a045b5b391107d194df/libs/boost/Makefile#L485
Matthias Schiffer Aug. 24, 2020, 6:39 p.m. UTC | #5
On 8/24/20 7:56 PM, Paul Spooren wrote:
> 
> On 24.08.20 00:55, Jo-Philipp Wich wrote:
>> Hi,
>>
>>> rules.mk always passes these as -I/-L to the toolchain.
>>>
>>> Fixes rare errors like:
>>> cc1: error: staging_dir/target-aarch64_cortex-a53_musl/usr/include: No
>>> such file or directory [-Werror=missing-include-dirs]
>>>
>>> Signed-off-by: Andre Heider <a.heider@gmail.com>
>> NAK - I'd prefer if we remove the faulty/redundant/unused include paths
>> from rules.mk instead.
> 
> Isn't that breaking some packages which currently use `/usr/lib`?
> 
> packages.git/boost:
> https://github.com/openwrt/packages/blob/e2e152da599ceeacf06b4a045b5b391107d194df/libs/boost/Makefile#L485


Pretty much all packages stage into staging_dir/target-*/usr - I don't
think there are any -I/-L flags we can remove.

As toolchain-provided headers are installed to a separate staging
directory, it is conceivable that with sufficiently bad luck a package that
sets -Werror=missing-include-dirs is built before the first package is
staged. Creating these directories in PrepareStaging seems like a good
solution to me.



Side note:

Package/*/install takes care of installing files for creating opkg
packages; this are irrelevant for staging. For staging_dir, the sections
Host/Install and Build/InstallDev are relevant (in the case of
staging_dir/target-..., the latter). This also happens in the file Paul
referenced, just not in the line he highlighted.
Jo-Philipp Wich Aug. 25, 2020, 6:40 a.m. UTC | #6
Hi,

> Isn't that breaking some packages which currently use `/usr/lib`?
> 
> packages.git/boost:
> https://github.com/openwrt/packages/blob/e2e152da599ceeacf06b4a045b5b391107d194df/libs/boost/Makefile#L485

I don't see how. The code you quoted creates the destination directory
directly in the line before.

~ Jo
Jo-Philipp Wich Aug. 25, 2020, 7:04 a.m. UTC | #7
Hi,

> Pretty much all packages stage into staging_dir/target-*/usr - I don't
> think there are any -I/-L flags we can remove.

we're patching the gcc specs [1], [2] to implicitly add $STAGING_DIR/usr/lib
to the link- and $STAGING_DIR/usr/include to the CPP flags. There is no need
to globally pass these as -I and -L flags respectively.

And indeed, I just successfully completed a test build with the following
patch applied:

-- 8< --
diff --git a/rules.mk b/rules.mk
index 45d96d6be4..d3a4073f6d 100644
--- a/rules.mk
+++ b/rules.mk
@@ -174,8 +174,6 @@ TARGET_CFLAGS:=$(TARGET_OPTIMIZATION)$(if $(CONFIG_DEBUG),
-g3) $(call qstrip,$(
 TARGET_CXXFLAGS = $(TARGET_CFLAGS)
 TARGET_ASFLAGS_DEFAULT = $(TARGET_CFLAGS)
 TARGET_ASFLAGS = $(TARGET_ASFLAGS_DEFAULT)
-TARGET_CPPFLAGS:=-I$(STAGING_DIR)/usr/include
-TARGET_LDFLAGS:=-L$(STAGING_DIR)/usr/lib -L$(STAGING_DIR)/lib
 ifneq ($(CONFIG_EXTERNAL_TOOLCHAIN),)
 LIBGCC_S_PATH=$(realpath $(wildcard $(call
qstrip,$(CONFIG_LIBGCC_ROOT_DIR))/$(call qstrip,$(CONFIG_LIBGCC_FILE_SPEC))))
 LIBGCC_S=$(if $(LIBGCC_S_PATH),-L$(dir $(LIBGCC_S_PATH)) -lgcc_s)
-- >8 --

~ Jo


[1]
https://git.openwrt.org/?p=openwrt/openwrt.git;a=blob;f=toolchain/gcc/final/Makefile#l86
[2]
https://git.openwrt.org/?p=openwrt/openwrt.git;a=blob;f=scripts/patch-specs.sh#l37
Andre Heider Aug. 25, 2020, 7:49 a.m. UTC | #8
Hi,

On 25/08/2020 09:04, Jo-Philipp Wich wrote:
> Hi,
> 
>> Pretty much all packages stage into staging_dir/target-*/usr - I don't
>> think there are any -I/-L flags we can remove.
> 
> we're patching the gcc specs [1], [2] to implicitly add $STAGING_DIR/usr/lib
> to the link- and $STAGING_DIR/usr/include to the CPP flags. There is no need
> to globally pass these as -I and -L flags respectively.
> 
> And indeed, I just successfully completed a test build with the following
> patch applied:

I missed the specs file, and indeed, those two lines are redundant and 
can be removed.

But still, with just your patch I get the same build error as before. 
The directories are passed to the toolchain, but don't yet exist 
(depending on the target/package selection I guess). My patch on top of 
yours fixes it again.

Regards,
Andre
diff mbox series

Patch

diff --git a/tools/Makefile b/tools/Makefile
index f038c90ba9..325c0995ee 100644
--- a/tools/Makefile
+++ b/tools/Makefile
@@ -123,7 +123,7 @@  define PrepareStaging
 		$(if $(QUIET),,set -x;) \
 		mkdir -p "$$dir"; \
 		cd "$$dir"; \
-		mkdir -p bin lib stamp; \
+		mkdir -p bin lib stamp usr/include usr/lib; \
 	); done
 endef