-
Notifications
You must be signed in to change notification settings - Fork 25
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
Build::SearchDep plugin appears to override compiler flags in share compilations #293
Comments
I think unfortunately this is a problem with autotools. If a dep requires a library but doesn't use pkg-config, often the only way of adding it is often using |
In the case of GDAL, it does not use any environment variables by default but the env vars do override the defaults when present. The -O2 is set somewhere in the build system at configure time (I cannot find exactly where at the moment). A doc patch seems the simplest approach. How about something like this added to the POD? Possibly in the description section, but perhaps in a distinct caveats section.
I can work up a PR if you'd like. |
Yeah I was thinking a CAVEAT, but we can put it in the DESCRIPTION section. I think one thing that we need to be careful of is qualifying the issue. I'm thinking the language should be more like:
Will this override local environment variables? ie, if a locally I have CFALGS set to One way is that we could provide a default value for these environment variables if they are not set. That way if you know |
Basically we want to be able to say $ENV{CFLAGS} = '-O3' unless defined $ENV{CFLAGS}; except just around the execution of the build. |
If I read the plugin code correctly, it already appends to existing env vars. The issue with the gdal and proj builds is that they are set somewhere in the configure system and are overridden by any env vars. I'm not familiar enough with autotools to know how passing CFLAGS and CXXFLAGS args to configure interacts with user defined env vars. |
Right but if we set the value to what we expect the default should be for the package if (and only if) the variable is not set, then we effectively get the same default as the alienized package, but also allow the user to specify
Need to experiment :) |
The autoconf plugin might be the right place to do this actually. |
Any such settings are probably best done in the relevant alienfile given the potential variability of default flags. Or I am misunderstanding this point.
I was hoping to avoid that :) Will give it a poke. |
No, that is exactly the point, I was musing on the best way for AB to do it once the alienfile tells it what the default should be. Does that make sense? |
I've experimented with Alien::proj, and passing CFLAGS and CXXFLAGS args to the configure call does override any env vars. Any alienfile is thus best to append or prepend these to the relevant env vars, as you suggested in #293 (comment) Or more simply for the alienfile, they could be passed as arguments to the plugin. There is of course the issue of the alienfile getting out of synch with the package being built, but that could be handled via a doc note for Alien maintainers. |
That reminds me we should document CXXFLAGS I think only CFLAGS and LIBS are mentioned in the documentation.
Yeah unfortunately unavoidable with the way that autoconf is structured. |
Just a note that some Alien packages don't work with I ended up using an around hook for that one. For others coming along later: share {
# usual code
...
meta->around_hook( build => \&set_compiler_flags );
build [
...
]
}
sub set_compiler_flags {
my ($orig, $build, @args) = @_;
local $ENV{CFLAGS} = '-O2 ' . ($ENV{CFLAGS} // '');
local $ENV{CXXFLAGS} = '-O2 ' . ($ENV{CXXFLAGS} // '');
$build->log ("Setting compiler flag env vars to -O2");
$orig->($build, @args);
} |
It seems that Alien::Build can override default compiler flags under autotools systems.
Relevant discussion is on the GDAL issue tracker: OSGeo/gdal#4706 (comment)
So far as I can tell the issue only occurs when Alien::Build::Plugin::SearchDep is used, as the behaviour is only evidenced on aliens that include it and which use autotools. I have observed it with Alien::gdal and Alien::proj, but not with Alien::libtiff or Alien::sqlite. Just as a data point, Alien::geos::af uses cmake and does not have this issue.
My current approach in the affected alienfiles is to add
CFLAGS='-O2' CXXFLAGS='-O2'
to the configure calls.I am not sure what the best fix is, or even if there is such a thing given the default flags will vary by package. Probing the configure script might be feasible, but perhaps documenting this situation and the workaround is the simplest thing.
Possibly relevant code is:
Alien-Build/lib/Alien/Build/Plugin/Build/SearchDep.pm
Lines 73 to 115 in fdd350a
The text was updated successfully, but these errors were encountered: