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

--search-prefix doesn't integrate with the value of --sysroot during crossbuild #20591

Closed
tranzystorekk opened this issue Jul 12, 2024 · 2 comments
Labels
bug Observed behavior contradicts documented or intended behavior

Comments

@tranzystorekk
Copy link

Zig Version

0.13.0

Steps to Reproduce and Observed Behavior

When testing the 0.13.0 bump for the zig package on Void Linux, trying to build a package like river 0.3.3 in cross errors when --sysroot <sysroot> is set but --search-prefix /usr is used, instead of --search-prefix <sysroot>/usr:

river_aarch64_do_build.log

Expected Behavior

--search-prefix /usr should work when correct sysroot is provided in --sysroot

@tranzystorekk tranzystorekk added the bug Observed behavior contradicts documented or intended behavior label Jul 12, 2024
@BratishkaErik
Copy link
Contributor

Zig Version

0.13.0

Steps to Reproduce and Observed Behavior

When testing the 0.13.0 bump for the zig package on Void Linux, trying to build a package like river 0.3.3 in cross errors when --sysroot <sysroot> is set but --search-prefix /usr is used, instead of --search-prefix <sysroot>/usr:

river_aarch64_do_build.log

Expected Behavior

--search-prefix /usr should work when correct sysroot is provided in --sysroot

IIRC it's recommended to use --search-prefix --libc with prepended paths instead of using --sysroot, and (at least on Linux) it's used by compiler only to pass it to LLD so that it enables cross-compiling mode and doesn't complain about "dynamic linker not found". prefix should be added to the parameter and zig_libc.txt manually before invocation then.
#19044 (comment)

IIRC it's also planned to remove --sysroot option entirely when self-hosted linker replaces lld, because it would serve no purpose.

Smth like this should work:

cat <<- _EOF_ > "zig_libc.txt"
			# Note: they are not prepended by "--sysroot" value, so repeat it here.
			include_dir=${XBPS_CROSS_BASE}/usr/include/
			sys_include_dir=${XBPS_CROSS_BASE}/usr/include/
			crt_dir=${XBPS_CROSS_BASE}/usr/lib/
			# Windows with MSVC only.
			msvc_lib_dir=
			# Windows with MSVC only.
			kernel32_lib_dir=
			# Haiku only.
			gcc_dir=
		_EOF_

--sysroot "${XBPS_CROSS_BASE}/" --search-prefix "${XBPS_CROSS_BASE}/usr/" --libc zig_libc.txt

gentoo/gentoo#37283

@tranzystorekk
Copy link
Author

Ah okay, we already had zig_libc.txt set up as above. So I understand that prepending the sysroot to search prefix is the correct approach here after all?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Observed behavior contradicts documented or intended behavior
Projects
None yet
Development

No branches or pull requests

2 participants