Skip to contentSkip to conversation

ulog compilation issue with buildroot 2022.02.2

Buildroot Andreas Ziegler 6 participants 7 messages Jun 5, 2022 – Jun 7, 2022 1 message not in the archive

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

#1 lore raw

Hi Nicolas,

Quoted 4 lines · Nicolas Carrier

Shoot, apparently, I failed when testing yesterday.
The ulog build issue is present on master too, contrary to what I said earlier.

So now, we have no clue at all :/

Alchemy is missing the correct library path for the Buildroot staging directory.

This is the environment when alchemy is called from Buildroot:

ALCHEMY_TARGET_ENV = \
	$(TARGET_MAKE_ENV) \
	ALCHEMY_HOME=$(ALCHEMY_HOME) \
	ALCHEMY_WORKSPACE_DIR="$(@D)" \
	ALCHEMY_TARGET_OUT=alchemy-out \
	PKGCONFIG_BIN=$(PKG_CONFIG_HOST_BINARY) \
	TARGET_OS=linux \
	TARGET_OS_FLAVOUR=buildroot \
	TARGET_CROSS="$(TARGET_CROSS)" \
	TARGET_ARCH=xxx \
	TARGET_GLOBAL_CXXFLAGS="$(TARGET_CXXFLAGS)" \
	TARGET_GLOBAL_LDFLAGS="$(TARGET_LDFLAGS)" \
	                       ^ LDFLAGS are usually empty
	TARGET_GLOBAL_FFLAGS="$(TARGET_FCFLAGS)" \
	TARGET_GLOBAL_FCFLAGS="$(TARGET_FCFLAGS)"

Alchemy adds more settings to LDFLAGS, this is the final content:

+ TARGET_GLOBAL_LDFLAGS = -O2 -Wl,-O1 -Lalchemy-out/staging/lib/arm-linux-gnueabihf -Lalchemy-out/staging/lib -Lalchemy-out/staging/usr/lib/arm-linux-gnueabihf -Lalchemy-out/staging/usr/lib -Wl,-rpath-link=alchemy-out/staging/lib/arm-linux-gnueabihf -Wl,-rpath-link=alchemy-out/staging/lib -Wl,-rpath-link=alchemy-out/staging/usr/lib/arm-linux-gnueabihf -Wl,-rpath-link=alchemy-out/staging/usr/lib

Adding the Buildroot staging library path to LDFLAGS makes the build succeed:

	...
	TARGET_GLOBAL_LDFLAGS="$(TARGET_LDFLAGS) -L$(STAGING_DIR)/usr/lib" \
	...

This is just a workaround; ideally Buildroot should establish itself as a toolchain 'flavour'. Unfortunately, alchemy is not very well documented :-[

Kind regards,
Andreas

Quoted 56 lines · Nicolas Carrier
Quoted 55 lines

And I redid the test with the working config (that is, without the SYSTEMD line) and this time there
are only:

output/host/opt/ext-toolchain/arm-linux-gnueabihf/libc/usr/lib/libpthread.so: ASCII text output/host/arm-buildroot-linux-gnueabihf/sysroot/usr/lib/libpthread.so:????? ASCII text

But their content is the same:

/* GNU ld script
?? Use the shared library, but some functions are only in ?? the static library, so try that secondarily.? */ OUTPUT_FORMAT(elf32-littlearm)
GROUP ( /lib/libpthread.so.0 /usr/lib/libpthread_nonshared.a )

Quoted 38 lines · Nicolas Carrier

Great, at least, I'm not alone :)

One other thing to notice is that there libpthread.so ascii files in the output directory, the content of which doesn't seem correct:

output/build/ulog-0389d243352255f6182326dccdae3d56dadc078f/alchemy- out/staging/lib/libpthread.so:
ASCII text output/host/opt/ext-toolchain/arm-linux-gnueabihf/libc/usr/lib/libpthread.so:??????????????????? ASCII text output/host/arm-buildroot-linux-gnueabihf/sysroot/usr/lib/libpthread.so:???????????????????????? ASCII text

They all contain:

/* GNU ld script
?? Use the shared library, but some functions are only in ?? the static library, so try that secondarily.? */ OUTPUT_FORMAT(elf32-littlearm)
GROUP ( /lib/libpthread.so.0 /usr/lib/libpthread_nonshared.a )

Quoted 15 lines · Thomas Petazzoni

CAUTION: This email originated from outside of the organization.
Do not click links or open attachments unless you recognize the sender and know the content is safe.

Quoted 7 lines · On Fri, 03 Jun 2022 11:09:48 +0200 Nicolas Carrier…

Hello,
I tested this morning against the master of buildroot (with an ubuntu 20.04) and the issue doesn't
appear anymore.
So there must be some change "recently" merged, which solves the issue.

An idea anyone?

Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

Not yet an idea, but I confirm that I was able to reproduce on 2022.02.2 (just so you know that your e-mail and issue have been seen!)

Thomas
--
Thomas Petazzoni, co-owner and CEO, Bootlin Embedded Linux and Kernel engineering and training
https://bootlin.com

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

#2 lore raw

Hello Andreas,

Quoted 29 lines · On Sun, 05 Jun 2022 06:05:09 +0000 Andreas Ziegler <[email protected]> wrote:

This is the environment when alchemy is called from Buildroot:

ALCHEMY_TARGET_ENV = \
	$(TARGET_MAKE_ENV) \
	ALCHEMY_HOME=$(ALCHEMY_HOME) \
	ALCHEMY_WORKSPACE_DIR="$(@D)" \
	ALCHEMY_TARGET_OUT=alchemy-out \
	PKGCONFIG_BIN=$(PKG_CONFIG_HOST_BINARY) \
	TARGET_OS=linux \
	TARGET_OS_FLAVOUR=buildroot \
	TARGET_CROSS="$(TARGET_CROSS)" \
	TARGET_ARCH=xxx \
	TARGET_GLOBAL_CXXFLAGS="$(TARGET_CXXFLAGS)" \
	TARGET_GLOBAL_LDFLAGS="$(TARGET_LDFLAGS)" \
	                       ^ LDFLAGS are usually empty
	TARGET_GLOBAL_FFLAGS="$(TARGET_FCFLAGS)" \
	TARGET_GLOBAL_FCFLAGS="$(TARGET_FCFLAGS)"

Alchemy adds more settings to LDFLAGS, this is the final content:

+ TARGET_GLOBAL_LDFLAGS = -O2 -Wl,-O1

(quoted diff) +0 -7
-Lalchemy-out/staging/lib/arm-linux-gnueabihf -Lalchemy-out/staging/lib 
-Lalchemy-out/staging/usr/lib/arm-linux-gnueabihf 
-Lalchemy-out/staging/usr/lib 
-Wl,-rpath-link=alchemy-out/staging/lib/arm-linux-gnueabihf 
-Wl,-rpath-link=alchemy-out/staging/lib 
-Wl,-rpath-link=alchemy-out/staging/usr/lib/arm-linux-gnueabihf 
-Wl,-rpath-link=alchemy-out/staging/usr/lib
Quoted 5 lines

Adding the Buildroot staging library path to LDFLAGS makes the build succeed:

	...
	TARGET_GLOBAL_LDFLAGS="$(TARGET_LDFLAGS) -L$(STAGING_DIR)/usr/lib" \

Thanks for your investigation!

-L$(STAGING_DIR)/usr/lib should normally not be needed, because $(STAGING_DIR)/usr/lib is in the default search path of the cross-compiler, as the compiler has $(STAGING_DIR)/usr as its sysroot.

So from a cross-compiler perspective, -L$(STAGING_DIR)/usr/lib should normally not be needed, and that's why it's not in $(TARGET_LDFLAGS).

Also, there is a curious thing in the report from Nicolas: the error happens when systemd is enabled, but doesn't happen when systemd is disabled.

Thomas

Signature · 7 lines
Thomas Petazzoni, co-owner and CEO, Bootlin
Embedded Linux and Kernel engineering and training
https://bootlin.com
_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot
#3 lore raw

Hi Thomas,

Quoted 43 lines · Thomas Petazzoni

Hello Andreas,

Quoted 30 lines · On Sun, 05 Jun 2022 06:05:09 +0000 Andreas Ziegler <[email protected]> wrote:

This is the environment when alchemy is called from Buildroot:

ALCHEMY_TARGET_ENV = \
	$(TARGET_MAKE_ENV) \
	ALCHEMY_HOME=$(ALCHEMY_HOME) \
	ALCHEMY_WORKSPACE_DIR="$(@D)" \
	ALCHEMY_TARGET_OUT=alchemy-out \
	PKGCONFIG_BIN=$(PKG_CONFIG_HOST_BINARY) \
	TARGET_OS=linux \
	TARGET_OS_FLAVOUR=buildroot \
	TARGET_CROSS="$(TARGET_CROSS)" \
	TARGET_ARCH=xxx \
	TARGET_GLOBAL_CXXFLAGS="$(TARGET_CXXFLAGS)" \
	TARGET_GLOBAL_LDFLAGS="$(TARGET_LDFLAGS)" \
	                       ^ LDFLAGS are usually empty
	TARGET_GLOBAL_FFLAGS="$(TARGET_FCFLAGS)" \
	TARGET_GLOBAL_FCFLAGS="$(TARGET_FCFLAGS)"

Alchemy adds more settings to LDFLAGS, this is the final content:

+ TARGET_GLOBAL_LDFLAGS = -O2 -Wl,-O1

(quoted diff) +0 -8
-Lalchemy-out/staging/lib/arm-linux-gnueabihf 
-Lalchemy-out/staging/lib
-Lalchemy-out/staging/usr/lib/arm-linux-gnueabihf
-Lalchemy-out/staging/usr/lib
-Wl,-rpath-link=alchemy-out/staging/lib/arm-linux-gnueabihf
-Wl,-rpath-link=alchemy-out/staging/lib
-Wl,-rpath-link=alchemy-out/staging/usr/lib/arm-linux-gnueabihf
-Wl,-rpath-link=alchemy-out/staging/usr/lib
Quoted 5 lines

Adding the Buildroot staging library path to LDFLAGS makes the build succeed:

	...
	TARGET_GLOBAL_LDFLAGS="$(TARGET_LDFLAGS) -L$(STAGING_DIR)/usr/lib" \

Thanks for your investigation!

Quoted 6 lines

-L$(STAGING_DIR)/usr/lib should normally not be needed, because $(STAGING_DIR)/usr/lib is in the default search path of the cross-compiler, as the compiler has $(STAGING_DIR)/usr as its sysroot.

So from a cross-compiler perspective, -L$(STAGING_DIR)/usr/lib should normally not be needed, and that's why it's not in $(TARGET_LDFLAGS).

And sysroot is detected by alchemy:

+ TARGET_TOOLCHAIN_SYSROOT = /home/data/test/autobuild/host/arm-buildroot-linux-gnueabihf/sysroot

Quoted 3 lines

Also, there is a curious thing in the report from Nicolas: the error happens when systemd is enabled, but doesn't happen when systemd is disabled.

I can confirm this. Adding BR2_INIT_SYSTEMD=y breaks the build (using make clean && make ulog).

Kind regards,
Andreas

Quoted 5 lines

Thomas
--
Thomas Petazzoni, co-owner and CEO, Bootlin Embedded Linux and Kernel engineering and training
https://bootlin.com

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

#4 lore raw

Hello,

Le 05/06/2022 à 13:46, Andreas Ziegler a écrit :

Quoted 49 lines

Hi Thomas,

Quoted 46 lines · Thomas Petazzoni

Hello Andreas,

Quoted 29 lines · On Sun, 05 Jun 2022 06:05:09 +0000 Andreas Ziegler <[email protected]> wrote:

This is the environment when alchemy is called from Buildroot:

ALCHEMY_TARGET_ENV = \
    $(TARGET_MAKE_ENV) \
    ALCHEMY_HOME=$(ALCHEMY_HOME) \
    ALCHEMY_WORKSPACE_DIR="$(@D)" \
    ALCHEMY_TARGET_OUT=alchemy-out \
    PKGCONFIG_BIN=$(PKG_CONFIG_HOST_BINARY) \
    TARGET_OS=linux \
    TARGET_OS_FLAVOUR=buildroot \
    TARGET_CROSS="$(TARGET_CROSS)" \
    TARGET_ARCH=xxx \
    TARGET_GLOBAL_CXXFLAGS="$(TARGET_CXXFLAGS)" \
    TARGET_GLOBAL_LDFLAGS="$(TARGET_LDFLAGS)" \
                           ^ LDFLAGS are usually empty TARGET_GLOBAL_FFLAGS="$(TARGET_FCFLAGS)" \
    TARGET_GLOBAL_FCFLAGS="$(TARGET_FCFLAGS)"

Alchemy adds more settings to LDFLAGS, this is the final content:

+ TARGET_GLOBAL_LDFLAGS = -O2 -Wl,-O1

(quoted diff) +0 -7
-Lalchemy-out/staging/lib/arm-linux-gnueabihf -Lalchemy-out/staging/lib
-Lalchemy-out/staging/usr/lib/arm-linux-gnueabihf
-Lalchemy-out/staging/usr/lib
-Wl,-rpath-link=alchemy-out/staging/lib/arm-linux-gnueabihf
-Wl,-rpath-link=alchemy-out/staging/lib
-Wl,-rpath-link=alchemy-out/staging/usr/lib/arm-linux-gnueabihf
-Wl,-rpath-link=alchemy-out/staging/usr/lib
Quoted 5 lines

Adding the Buildroot staging library path to LDFLAGS makes the build succeed:

    ...
    TARGET_GLOBAL_LDFLAGS="$(TARGET_LDFLAGS) -L$(STAGING_DIR)/usr/lib" \

Thanks for your investigation!

-L$(STAGING_DIR)/usr/lib should normally not be needed, because $(STAGING_DIR)/usr/lib is in the default search path of the cross-compiler, as the compiler has $(STAGING_DIR)/usr as its sysroot.

Quoted 7 lines
Quoted 2 lines

So from a cross-compiler perspective, -L$(STAGING_DIR)/usr/lib should normally not be needed, and that's why it's not in $(TARGET_LDFLAGS).

And sysroot is detected by alchemy:

+ TARGET_TOOLCHAIN_SYSROOT = /home/data/test/autobuild/host/arm-buildroot-linux-gnueabihf/sysroot

Yes but alchemy try to copy some files from staging directory to ulog/alchemy-out/staging

See _libc_installed_file target in output/host/opt/alchemy/toolchains/libc.mk.

If we hack into _libc_installed_file rule to not copy any files from staging, the build succeed.

Quoted 7 lines
Quoted 4 lines

Also, there is a curious thing in the report from Nicolas: the error happens when systemd is enabled, but doesn't happen when systemd is disabled.

I can confirm this. Adding BR2_INIT_SYSTEMD=y breaks the build (using make clean && make ulog).

I did a try without systemd but the build failed.

Best regards,
Romain

Quoted 9 lines

Kind regards,
Andreas

Quoted 5 lines

Thomas

Signature · 3 lines
Thomas Petazzoni, co-owner and CEO, Bootlin
Embedded Linux and Kernel engineering and training
https://bootlin.com
Quoted 4 lines

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

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

#5 lore raw

Greetings all -

Quoted 55 lines · Romain Naour

Hello,

Le 05/06/2022 à 13:46, Andreas Ziegler a écrit :

Quoted 52 lines

Hi Thomas,

Quoted 48 lines · Thomas Petazzoni

Hello Andreas,

Quoted 29 lines · On Sun, 05 Jun 2022 06:05:09 +0000 Andreas Ziegler <[email protected]> wrote:

This is the environment when alchemy is called from Buildroot:

ALCHEMY_TARGET_ENV = \
    $(TARGET_MAKE_ENV) \
    ALCHEMY_HOME=$(ALCHEMY_HOME) \
    ALCHEMY_WORKSPACE_DIR="$(@D)" \
    ALCHEMY_TARGET_OUT=alchemy-out \
    PKGCONFIG_BIN=$(PKG_CONFIG_HOST_BINARY) \
    TARGET_OS=linux \
    TARGET_OS_FLAVOUR=buildroot \
    TARGET_CROSS="$(TARGET_CROSS)" \
    TARGET_ARCH=xxx \
    TARGET_GLOBAL_CXXFLAGS="$(TARGET_CXXFLAGS)" \
    TARGET_GLOBAL_LDFLAGS="$(TARGET_LDFLAGS)" \
                           ^ LDFLAGS are usually empty TARGET_GLOBAL_FFLAGS="$(TARGET_FCFLAGS)" \
    TARGET_GLOBAL_FCFLAGS="$(TARGET_FCFLAGS)"

Alchemy adds more settings to LDFLAGS, this is the final content:

+ TARGET_GLOBAL_LDFLAGS = -O2 -Wl,-O1

(quoted diff) +0 -7
-Lalchemy-out/staging/lib/arm-linux-gnueabihf -Lalchemy-out/staging/lib
-Lalchemy-out/staging/usr/lib/arm-linux-gnueabihf
-Lalchemy-out/staging/usr/lib
-Wl,-rpath-link=alchemy-out/staging/lib/arm-linux-gnueabihf
-Wl,-rpath-link=alchemy-out/staging/lib
-Wl,-rpath-link=alchemy-out/staging/usr/lib/arm-linux-gnueabihf
-Wl,-rpath-link=alchemy-out/staging/usr/lib
Quoted 5 lines

Adding the Buildroot staging library path to LDFLAGS makes the build succeed:

    ...
    TARGET_GLOBAL_LDFLAGS="$(TARGET_LDFLAGS) -L$(STAGING_DIR)/usr/lib" \

Thanks for your investigation!

-L$(STAGING_DIR)/usr/lib should normally not be needed, because $(STAGING_DIR)/usr/lib is in the default search path of the cross-compiler, as the compiler has $(STAGING_DIR)/usr as its sysroot.

So from a cross-compiler perspective, -L$(STAGING_DIR)/usr/lib should normally not be needed, and that's why it's not in $(TARGET_LDFLAGS).

Quoted 8 lines
Quoted 4 lines

And sysroot is detected by alchemy:

+ TARGET_TOOLCHAIN_SYSROOT = /home/data/test/autobuild/host/arm-buildroot-linux-gnueabihf/sysroot

Yes but alchemy try to copy some files from staging directory to ulog/alchemy-out/staging

And it seems that the files copied is different between the working (w/o systemd) and non-working (w/ systemd) builds.

Looking at sysroot in a working build, it only copies the two files from the lib/ directory:
./host/arm-buildroot-linux-gnueabihf/sysroot/usr/lib/libpthread_nonshared.a ./host/arm-buildroot-linux-gnueabihf/sysroot/usr/lib/libpthread.so ./host/arm-buildroot-linux-gnueabihf/sysroot/usr/lib/libpthread.a ./host/arm-buildroot-linux-gnueabihf/sysroot/lib/libpthread-2.25.so ./host/arm-buildroot-linux-gnueabihf/sysroot/lib/libpthread.so.0

Whereas in the non-working build, the files are all in the usr/lib/ directory:
./host/arm-buildroot-linux-gnueabihf/sysroot/usr/lib/libpthread_nonshared.a ./host/arm-buildroot-linux-gnueabihf/sysroot/usr/lib/libpthread-2.25.so ./host/arm-buildroot-linux-gnueabihf/sysroot/usr/lib/libpthread.so ./host/arm-buildroot-linux-gnueabihf/sysroot/usr/lib/libpthread.a
./host/arm-buildroot-linux-gnueabihf/sysroot/usr/lib/libpthread.so.0

In this case, it also copies the libpthread.so file which is an ld script where I think it is getting the bad path:
/* GNU ld script
Use the shared library, but some functions are only in
the static library, so try that secondarily. */
OUTPUT_FORMAT(elf32-littlearm)
GROUP ( /lib/libpthread.so.0 /usr/lib/libpthread_nonshared.a )

Is there something in the systemd configuration/build that is creating this script file?

.Tim
Tim D. Hammer
[email protected]

Quoted 33 lines

See _libc_installed_file target in output/host/opt/alchemy/toolchains/libc.mk.

If we hack into _libc_installed_file rule to not copy any files from staging, the build succeed.

Quoted 7 lines
Quoted 4 lines

Also, there is a curious thing in the report from Nicolas: the error happens when systemd is enabled, but doesn't happen when systemd is disabled.

I can confirm this. Adding BR2_INIT_SYSTEMD=y breaks the build (using make clean && make ulog).

I did a try without systemd but the build failed.

Best regards,
Romain

Quoted 9 lines

Kind regards,
Andreas

Quoted 5 lines

Thomas

Signature · 3 lines
Thomas Petazzoni, co-owner and CEO, Bootlin
Embedded Linux and Kernel engineering and training
https://bootlin.com
Quoted 4 lines

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

Quoted 4 lines

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

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

#6 lore raw
Quoted 85 lines · Tim Hammer

Greetings all -

Quoted 55 lines · Romain Naour

Hello,

Le 05/06/2022 à 13:46, Andreas Ziegler a écrit :

Quoted 52 lines

Hi Thomas,

Quoted 48 lines · Thomas Petazzoni

Hello Andreas,

Quoted 29 lines · On Sun, 05 Jun 2022 06:05:09 +0000 Andreas Ziegler <[email protected]> wrote:

This is the environment when alchemy is called from Buildroot:

ALCHEMY_TARGET_ENV = \
    $(TARGET_MAKE_ENV) \
    ALCHEMY_HOME=$(ALCHEMY_HOME) \
    ALCHEMY_WORKSPACE_DIR="$(@D)" \
    ALCHEMY_TARGET_OUT=alchemy-out \
    PKGCONFIG_BIN=$(PKG_CONFIG_HOST_BINARY) \
    TARGET_OS=linux \
    TARGET_OS_FLAVOUR=buildroot \
    TARGET_CROSS="$(TARGET_CROSS)" \
    TARGET_ARCH=xxx \
    TARGET_GLOBAL_CXXFLAGS="$(TARGET_CXXFLAGS)" \
    TARGET_GLOBAL_LDFLAGS="$(TARGET_LDFLAGS)" \
                           ^ LDFLAGS are usually empty TARGET_GLOBAL_FFLAGS="$(TARGET_FCFLAGS)" \
    TARGET_GLOBAL_FCFLAGS="$(TARGET_FCFLAGS)"

Alchemy adds more settings to LDFLAGS, this is the final content:

+ TARGET_GLOBAL_LDFLAGS = -O2 -Wl,-O1

(quoted diff) +0 -7
-Lalchemy-out/staging/lib/arm-linux-gnueabihf -Lalchemy-out/staging/lib
-Lalchemy-out/staging/usr/lib/arm-linux-gnueabihf
-Lalchemy-out/staging/usr/lib
-Wl,-rpath-link=alchemy-out/staging/lib/arm-linux-gnueabihf
-Wl,-rpath-link=alchemy-out/staging/lib
-Wl,-rpath-link=alchemy-out/staging/usr/lib/arm-linux-gnueabihf
-Wl,-rpath-link=alchemy-out/staging/usr/lib
Quoted 5 lines

Adding the Buildroot staging library path to LDFLAGS makes the build succeed:

    ...
    TARGET_GLOBAL_LDFLAGS="$(TARGET_LDFLAGS) -L$(STAGING_DIR)/usr/lib" \

Thanks for your investigation!

-L$(STAGING_DIR)/usr/lib should normally not be needed, because $(STAGING_DIR)/usr/lib is in the default search path of the cross-compiler, as the compiler has $(STAGING_DIR)/usr as its sysroot.

So from a cross-compiler perspective, -L$(STAGING_DIR)/usr/lib should normally not be needed, and that's why it's not in $(TARGET_LDFLAGS).

Quoted 8 lines
Quoted 4 lines

And sysroot is detected by alchemy:

+ TARGET_TOOLCHAIN_SYSROOT = /home/data/test/autobuild/host/arm-buildroot-linux-gnueabihf/sysroot

Yes but alchemy try to copy some files from staging directory to ulog/alchemy-out/staging

And it seems that the files copied is different between the working (w/o systemd) and non-working (w/ systemd) builds.

Looking at sysroot in a working build, it only copies the two files from the lib/ directory:
./host/arm-buildroot-linux-gnueabihf/sysroot/usr/lib/libpthread_nonshared.a ./host/arm-buildroot-linux-gnueabihf/sysroot/usr/lib/libpthread.so ./host/arm-buildroot-linux-gnueabihf/sysroot/usr/lib/libpthread.a ./host/arm-buildroot-linux-gnueabihf/sysroot/lib/libpthread-2.25.so ./host/arm-buildroot-linux-gnueabihf/sysroot/lib/libpthread.so.0

Whereas in the non-working build, the files are all in the usr/lib/ directory:
./host/arm-buildroot-linux-gnueabihf/sysroot/usr/lib/libpthread_nonshared.a ./host/arm-buildroot-linux-gnueabihf/sysroot/usr/lib/libpthread-2.25.so ./host/arm-buildroot-linux-gnueabihf/sysroot/usr/lib/libpthread.so ./host/arm-buildroot-linux-gnueabihf/sysroot/usr/lib/libpthread.a
./host/arm-buildroot-linux-gnueabihf/sysroot/usr/lib/libpthread.so.0

Quoted 7 lines

In this case, it also copies the libpthread.so file which is an ld script where I think it is getting the bad path:
/* GNU ld script
Use the shared library, but some functions are only in
the static library, so try that secondarily. */
OUTPUT_FORMAT(elf32-littlearm)
GROUP ( /lib/libpthread.so.0 /usr/lib/libpthread_nonshared.a )

With systemd, you automatically get BR2_ROOTFS_MERGED_USR, which means that
/lib is a symlink to /usr/lib. So /lib/libpthread.so.0 should still be a correct path.

Quoted 2 lines

Is there something in the systemd configuration/build that is creating this script file?

No, it's normal that libpthread.so is a linker script. It gets installed in
/lib by glibc - but with systemd, since /lib is a symlink to /usr/lib, it ends up there.

I can't find back the original issue, but I suspect the problem is that
ulog/alchemy calls ld directly (i.e. not gcc), which bypasses the toolchain wrapper and therefore bypasses the setting of sysroot. Although that doesn't explain why it would work on non-systemd (or non-merged-usr)...

Regards,
Arnout

Quoted 40 lines

.Tim
Tim D. Hammer
[email protected]

Quoted 33 lines

See _libc_installed_file target in output/host/opt/alchemy/toolchains/libc.mk.

If we hack into _libc_installed_file rule to not copy any files from staging, the build succeed.

Quoted 7 lines
Quoted 4 lines

Also, there is a curious thing in the report from Nicolas: the error happens when systemd is enabled, but doesn't happen when systemd is disabled.

I can confirm this. Adding BR2_INIT_SYSTEMD=y breaks the build (using make clean && make ulog).

I did a try without systemd but the build failed.

Best regards,
Romain

Quoted 13 lines

Kind regards,
Andreas

Quoted 5 lines

Thomas

Signature · 3 lines
Thomas Petazzoni, co-owner and CEO, Bootlin
Embedded Linux and Kernel engineering and training
https://bootlin.com

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

Quoted 8 lines
Quoted 4 lines

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

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

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

#7 lore raw
In reply to Andreas Ziegler

I confirm that the workaround works fine, thank you very much!

Quoted 66 lines · Andreas Ziegler

CAUTION: This email originated from outside of the organization.
Do not click links or open attachments unless you recognize the sender and know the content is safe.

Hi Thomas,

Quoted 43 lines · Thomas Petazzoni

Hello Andreas,

Quoted 30 lines · On Sun, 05 Jun 2022 06:05:09 +0000 Andreas Ziegler <[email protected]> wrote:

This is the environment when alchemy is called from Buildroot:

ALCHEMY_TARGET_ENV = \
     $(TARGET_MAKE_ENV) \
     ALCHEMY_HOME=$(ALCHEMY_HOME) \
     ALCHEMY_WORKSPACE_DIR="$(@D)" \
     ALCHEMY_TARGET_OUT=alchemy-out \
     PKGCONFIG_BIN=$(PKG_CONFIG_HOST_BINARY) \
     TARGET_OS=linux \
     TARGET_OS_FLAVOUR=buildroot \
     TARGET_CROSS="$(TARGET_CROSS)" \
     TARGET_ARCH=xxx \
     TARGET_GLOBAL_CXXFLAGS="$(TARGET_CXXFLAGS)" \
     TARGET_GLOBAL_LDFLAGS="$(TARGET_LDFLAGS)" \
                            ^ LDFLAGS are usually empty TARGET_GLOBAL_FFLAGS="$(TARGET_FCFLAGS)" \
     TARGET_GLOBAL_FCFLAGS="$(TARGET_FCFLAGS)"

Alchemy adds more settings to LDFLAGS, this is the final content:

+ TARGET_GLOBAL_LDFLAGS = -O2 -Wl,-O1

(quoted diff) +0 -8
-Lalchemy-out/staging/lib/arm-linux-gnueabihf
-Lalchemy-out/staging/lib
-Lalchemy-out/staging/usr/lib/arm-linux-gnueabihf
-Lalchemy-out/staging/usr/lib
-Wl,-rpath-link=alchemy-out/staging/lib/arm-linux-gnueabihf
-Wl,-rpath-link=alchemy-out/staging/lib
-Wl,-rpath-link=alchemy-out/staging/usr/lib/arm-linux-gnueabihf
-Wl,-rpath-link=alchemy-out/staging/usr/lib
Quoted 5 lines

Adding the Buildroot staging library path to LDFLAGS makes the build succeed:

     ...
     TARGET_GLOBAL_LDFLAGS="$(TARGET_LDFLAGS) -L$(STAGING_DIR)/usr/lib" \

Thanks for your investigation!

Quoted 6 lines

-L$(STAGING_DIR)/usr/lib should normally not be needed, because $(STAGING_DIR)/usr/lib is in the default search path of the cross-compiler, as the compiler has $(STAGING_DIR)/usr as its sysroot.

So from a cross-compiler perspective, -L$(STAGING_DIR)/usr/lib should normally not be needed, and that's why it's not in $(TARGET_LDFLAGS).

And sysroot is detected by alchemy:

+ TARGET_TOOLCHAIN_SYSROOT = /home/data/test/autobuild/host/arm-buildroot-linux-gnueabihf/sysroot

Quoted 3 lines

Also, there is a curious thing in the report from Nicolas: the error happens when systemd is enabled, but doesn't happen when systemd is disabled.

Quoted 11 lines

I can confirm this. Adding BR2_INIT_SYSTEMD=y breaks the build (using make clean && make ulog).

Kind regards,
Andreas

Quoted 5 lines

Thomas
--
Thomas Petazzoni, co-owner and CEO, Bootlin Embedded Linux and Kernel engineering and training
https://bootlin.com

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