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

RFE: Handle LIBRARY_PATH #121

Open
CendioOssman opened this issue Nov 5, 2021 · 5 comments
Open

RFE: Handle LIBRARY_PATH #121

CendioOssman opened this issue Nov 5, 2021 · 5 comments

Comments

@CendioOssman
Copy link

In our build system we sometimes use $LIBRARY_PATH rather than $LDFLAGS to control where the compiler searches for libraries. It would be a nice future feature if that variable could also be handled correctly, i.e. a separate $LIBRARY_PATH and $HOSTLIBRARY_PATH.

@arsv
Copy link
Owner

arsv commented Nov 6, 2021

What do you mean by handled correctly?

LIBRARY_PATH is used by gcc in native configurations, which is backwards from what you're describing and also requires no special handling on the part of perl-cross. The correct handling is to leave it in the environment, unchanged.

I've never heard of HOSTLIBRARY_PATH and neither has Google apparently.

@CendioOssman
Copy link
Author

I'm talking about this section here, where special HOST* versions of some compiler variables are used:

if [ "$mode" = 'target' -o "$mode" = 'native' ]; then
setfromenv ccflags CFLAGS
setfromenv ldflags LDFLAGS
if [ -n "$sysroot" ]; then
msg "Adding --sysroot to {cc,ld}flags"
prepend ccflags "--sysroot=$sysroot"
prepend ldflags "--sysroot=$sysroot"
# While cccdlflags are used together with ccflags,
# ld is always called with lddlflags *instead*of* ldflags
prepend lddlflags "--sysroot=$sysroot"
# Same for cpp
prepend cppflags "--sysroot=$sysroot"
fi
elif [ "$mode" = 'buildmini' ]; then
setfromenv ccflags HOSTCFLAGS
setfromenv ldflags HOSTLDFLAGS
fi

$LIBRARY_PATH would be slightly different in that it is picked up by the compiler rather than the configure script, but the principle is similar from a user point of view.

@arsv
Copy link
Owner

arsv commented Nov 13, 2021

Ok, and what should configure do about these variables in your opinion?

To clarify, I have a rough idea of what you're trying to do, but I don't understand what exactly you want changed in perl-cross specifically and why doing that would be a good idea.

@CendioOssman
Copy link
Author

My idea is basically this:

When you do normal builds, you set CFLAGS and LDFLAGS to get the proper settings you need. perl-cross is nice enough to magically handle these so that they still apply to the output binaries, even though you are now doing both native builds and cross builds.

In the same line of reasoning, for a normal build you could be using LIBRARY_PATH instead of using LDFLAGS to get the proper settings. This is where the magic in perl-cross currently no longer works as those settings are applied to the native binaries instead of the output ones.

So in order to have perl-cross continue along the principle of "just do what you do for a native build and perl-cross will sort everything out for a cross build", I think the following needs to be added:

  1. If building miniparl (i.e. native), then unset the current LIBRARY_PATH, and change HOSTLIBRARY_PATH to LIBRARY_PATH (if it exists)
  2. If building perl (i.e. cross) then keep any set LIBRARY_PATH.

@CendioOssman
Copy link
Author

There might be more to it though, I haven't dug that deep in to perl-cross. These variables need to have the above behaviour as ld is run, not just during the configure stage.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants