Skip to contentSkip to conversation

package/libxml-parser-perl: fix build when host matches target gcc

PATCH In review Norbert Lange 2 participants 3 messages Dec 10, 2022

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 package/libxml-parser-perl: fix build when host matches target gcc

The host configure and build step looks for same compiler name (eg. x86_64-linux-gnu-gcc), and the build potentially breaks if the target compiler is named identically.

revert PATH env variable to not include the target binaries.

---
 package/libxml-parser-perl/libxml-parser-perl.mk | 1 +
 1 file changed, 1 insertion(+)
package/libxml-parser-perl/libxml-parser-perl.mk +1 -0
index 37cef2e418..4af4485429 100644
@@ -14,6 +14,7 @@ LIBXML_PARSER_PERL_RUN_PERL = `which perl`
 
 HOST_LIBXML_PARSER_PERL_CONFIGURE_OPTS = \
 	$(HOST_CONFIGURE_OPTS) \
+	PATH="$(PATH)" \
 	LD="$(HOSTCC)"
 
 define HOST_LIBXML_PARSER_PERL_CONFIGURE_CMDS
Signature · 6 lines
2.35.1

_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot
#1 lore raw

Norbert, All,

On 2022-12-10 14:17 +0100, Norbert Lange spake thusly:

Quoted 5 lines

The host configure and build step looks for same compiler name (eg. x86_64-linux-gnu-gcc), and the build potentially breaks if the target compiler is named identically.

revert PATH env variable to not include the target binaries.

We pass $(HOST_CONFIGURE_OPTS) in the environment, which contains a definition for: CC=$(HOSTCC)

And HOSTCC is defined as:

ifndef HOSTCC
HOSTCC := gcc
HOSTCC := $(shell which $(HOSTCC) || type -p $(HOSTCC) || echo gcc) endif

In my case, however, I can indeed see that it uses it (single line wrapped for readability):

/usr/bin/gcc -c -I/home/ymorin/dev/buildroot/O/master/host/include -D_REENTRANT -D_GNU_SOURCE -DDEBIAN -fwrapv -fno-strict-aliasing -pipe -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -O2 -g -DVERSION=\"2.46\" -DXS_VERSION=\"2.46\" -fPIC
"-I/usr/lib/x86_64-linux-gnu/perl/5.30/CORE" Expat.c

So, I looked at the generated Makefile, and I can see;

# These definitions are from config.sh (via /usr/lib/x86_64-linux-gnu/perl/5.30/Config.pm). # They may have been overridden via Makefile.PL or on the command line.

So, we are passing CC et all in the environment, so they do not override the ones my system perl was built with.

We are also even forcing LD, but it is not accounted for either... I guess that _may_ work when we are building our own host-perl, but not when we are using the system perl...

So, I think the best fix would be to change how we pass CC et al, either by passing HOST_LIBXML_PARSER_PERL_CONFIGURE_OPTS as options instead of in the environment, or by carefully cherry-picking CC, LD and maybe a few others, and force them to be passed as options.

Regards,
Yann E. MORIN.

Quoted 24 lines
---
 package/libxml-parser-perl/libxml-parser-perl.mk | 1 +
 1 file changed, 1 insertion(+)
package/libxml-parser-perl/libxml-parser-perl.mk +1 -0
index 37cef2e418..4af4485429 100644
@@ -14,6 +14,7 @@ LIBXML_PARSER_PERL_RUN_PERL = `which perl`
 
 HOST_LIBXML_PARSER_PERL_CONFIGURE_OPTS = \
 	$(HOST_CONFIGURE_OPTS) \
+	PATH="$(PATH)" \
 	LD="$(HOSTCC)"
 
 define HOST_LIBXML_PARSER_PERL_CONFIGURE_CMDS
Signature · 6 lines
2.35.1

_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot
Signature · 10 lines
.-----------------.--------------------.------------------.--------------------.
|  Yann E. MORIN  | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: |
| +33 662 376 056 | Software  Designer | \ / CAMPAIGN     |  ___               |
| +33 561 099 427 `------------.-------:  X  AGAINST      |  \e/  There is no  |
| http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL    |   v   conspiracy.  |
'------------------------------^-------^------------------^--------------------'
_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot
#2 lore raw
Quoted 28 lines · On Sat, 10 Dec 2022, 17:18 Yann E. MORIN, <[email protected]> wrote:

Norbert, All,

On 2022-12-10 14:17 +0100, Norbert Lange spake thusly:

Quoted 5 lines

The host configure and build step looks for same compiler name (eg. x86_64-linux-gnu-gcc), and the build potentially breaks if the target compiler is named identically.

revert PATH env variable to not include the target binaries.

We pass $(HOST_CONFIGURE_OPTS) in the environment, which contains a definition for: CC=$(HOSTCC)

And HOSTCC is defined as:

ifndef HOSTCC
HOSTCC := gcc
HOSTCC := $(shell which $(HOSTCC) || type -p $(HOSTCC) || echo gcc) endif

In my case, however, I can indeed see that it uses it (single line wrapped for readability):

/usr/bin/gcc -c -I/home/ymorin/dev/buildroot/O/master/host/include -D_REENTRANT -D_GNU_SOURCE -DDEBIAN -fwrapv -fno-strict-aliasing -pipe -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -O2 -g -DVERSION=\"2.46\" -DXS_VERSION=\"2.46\" -fPIC
"-I/usr/lib/x86_64-linux-gnu/perl/5.30/CORE" Expat.c

Quoted 9 lines

So, I looked at the generated Makefile, and I can see;

# These definitions are from config.sh (via
/usr/lib/x86_64-linux-gnu/perl/5.30/Config.pm).
# They may have been overridden via Makefile.PL or on the command line.

So, we are passing CC et all in the environment, so they do not override the ones my system perl was built with.

I actually dont see where the compiler name comes from in my case

We are also even forcing LD, but it is not accounted for either... I

Quoted 8 lines

guess that _may_ work when we are building our own host-perl, but not when we are using the system perl...

So, I think the best fix would be to change how we pass CC et al, either by passing HOST_LIBXML_PARSER_PERL_CONFIGURE_OPTS as options instead of in the environment, or by carefully cherry-picking CC, LD and maybe a few others, and force them to be passed as options.

I actually forgot about it, thinking it has been accepted, but you find an earlier patch from myself at [1] (ML archive seems dead ATM?).

I think having the "wrong" compiler in path generally is asking for trouble, this package doesnt need any BR provided host-tools so its fine without. I don't know how to fix this in a clean manner for the general case (some host pkgs might just build with target compiler without anyone noticing).

perhaps install wrappers for the target toolchain in eg. $(HOST_DIR)/fake-bin/x86_64-linux-gnu-gcc

wrappers would print a warning (possibly break the build later, if the problem is
better understood), then forward the arguments to /usr/bin/x86_64-linux-gnu-gcc
(same thing for every target toolchain binary).

only on host configure/build/install steps the '$(HOST_DIR)/fake-bin' entry would be added in front of PATH.

regards,
Norbert

Quoted 41 lines

Regards,
Yann E. MORIN.

Review

Quoted 6 lines
---
 package/libxml-parser-perl/libxml-parser-perl.mk | 1 +
 1 file changed, 1 insertion(+)
(quoted diff) +0 -0

b/package/libxml-parser-perl/libxml-parser-perl.mk

Quoted 14 lines

index 37cef2e418..4af4485429 100644

package/libxml-parser-perl/libxml-parser-perl.mk +1 -1
@@ -14,6 +14,7 @@ LIBXML_PARSER_PERL_RUN_PERL = `which perl`
 
 HOST_LIBXML_PARSER_PERL_CONFIGURE_OPTS = \
      $(HOST_CONFIGURE_OPTS) \
+     PATH="$(PATH)" \
      LD="$(HOSTCC)"
 
 define HOST_LIBXML_PARSER_PERL_CONFIGURE_CMDS
--

2.35.1

Quoted 4 lines

_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot

--

.-----------------.--------------------.------------------.--------------------.

|  Yann E. MORIN  | Real-Time Embedded | /"\ ASCII RIBBON | Erics'
conspiracy: |
| +33 662 376 056 | Software  Designer | \ / CAMPAIGN     |  ___
     |
| +33 561 099 427 `------------.-------:  X  AGAINST      |  \e/  There is
no  |
| http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL    |   v
 conspiracy.  |
Quoted 2 lines

'------------------------------^-------^------------------^--------------------'

[1] - https://lists.buildroot.org/pipermail/buildroot/2020-June/284219.html

_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot