Bug #757

Don't match '-l' in '-L/usr/lib/x86_64-linux-gnu/hdf5/serial' in FindNETCDF _netcdf_dashl regex

Added by Bas over 1 year ago. Updated over 1 year ago.

Status:ClosedStart date:2015-08-24
Priority:NormalDue date:
Assignee:Florian% Done:

0%

Category:-
Target version:Candidate for next bugfix release
Affected version:5.1.x Platform:Linux

Description

The netcdf transition in Debian has started as part of the ongoing GCC 5 transitions in which netcdf was upgraded from 4.1.3 to 4.4.0-rc2.

The build of the gmt Debian package fails because the _netcdf_dashl regex in FindNETCDF incorrectly matches '-linux-gnu/hdf5/serial' as a linker flag.

The attached patch fixes the regex by requiring '-l' to be preceded a space or be the first character in the string.

netcdf-library-regex.patch Magnifier (969 Bytes) Bas, 2015-08-24 06:28

netcdf-library-regex2.patch Magnifier (1.86 KB) Bas, 2015-08-25 00:11

Associated revisions

Revision 14773
Added by Remko over 1 year ago

Ensure that when scanning the -l arguments, that '-L/usr/lib/x86_64-linux-gnu/hdf5/serial' is not seen as one.
Patch by Bas.
Fixes issue #757.

Revision 14776
Added by Remko over 1 year ago

Ensure that when scanning the -l arguments, that '-L/usr/lib/x86_64-linux-gnu/hdf5/serial' is not seen as one.
Fixes issue #757 for GMT 5.1
Use gzip -n to avoid timestamped gzipped files and hence support reproducible builds.
This fixed issue #759 for GMT 5.1
Patches provided by usr#937.

History

#1 Updated by Paul over 1 year ago

  • Status changed from New to In Progress
  • Assignee set to Florian

Passing this to Florian for review and adoption.

#2 Updated by Remko over 1 year ago

I see two issues with this patch.
  1. In the patch file there is this expression:
    string (REGEX REPLACE "(^| )-l" "" _netcdf_lib "${_netcdf_dashl}")

    In case the -l is preceded by a space, this will eat the space. I don't think that will hurt anybody, but I would like to point it out.
  2. I think the same should be done with the "-L", i.e.
    string (REGEX MATCHALL "(^| )-L[^ ]+" _netcdf_dashL ${NETCDF_CONFIG_LIBS})
    string (REGEX REPLACE "(^| )-L" "" _netcdf_libpath "${_netcdf_dashL}")

#3 Updated by Bas over 1 year ago

Remko wrote:

I see two issues with this patch.
  1. In the patch file there is this expression:
    [...]
    In case the -l is preceded by a space, this will eat the space. I don't think that will hurt anybody, but I would like to point it out.

That's why the REGEX REPLACE strips the preceding space too:

string (REGEX MATCHALL "(^| )-l[^ ]+" _netcdf_dashl ${NETCDF_CONFIG_LIBS})
string (REGEX REPLACE "(^| )-l" "" _netcdf_lib "${_netcdf_dashl}")

The resulting _netcdf_lib will be without spaces as expected:

netcdf;hdf5_hl;hdf5;pthread;z;dl;m;curl

Here's some debugging output of the variables in question without this patch:

-- NETCDF_CONFIG_CFLAGS(pre): -I/usr/include -I/usr/include/hdf5/serial
-- _netcdf_dashI: -I/usr/include;-I/usr/include/hdf5/serial
-- _netcdf_includepath: /usr/include;/usr/include/hdf5/serial
-- _netcdf_cflags_other:  
-- NETCDF_CONFIG_LIBS(pre): -L/usr/lib -L/usr/lib/x86_64-linux-gnu/hdf5/serial -lnetcdf -lhdf5_hl -lhdf5 -lpthread -lz -ldl -lm -lcurl
-- _netcdf_dashl: -linux-gnu/hdf5/serial;-lnetcdf;-lhdf5_hl;-lhdf5;-lpthread;-lz;-ldl;-lm;-lcurl
-- _netcdf_lib: inux-gnu/hdf5/serial;netcdf;hdf5_hl;hdf5;pthread;z;dl;m;curl
-- _netcdf_dashL: -L/usr/lib;-L/usr/lib/x86_64-linux-gnu/hdf5/serial
-- _netcdf_libpath: /usr/lib;/usr/lib/x86_64-linux-gnu/hdf5/serial
-- NETCDF_CONFIG_CFLAGS(post): -I/usr/include -I/usr/include/hdf5/serial
-- NETCDF_CONFIG_LIBS(post): -L/usr/lib -L/usr/lib/x86_64-linux-gnu/hdf5/serial -lnetcdf -lhdf5_hl -lhdf5 -lpthread -lz -ldl -lm -lcurl
-- _netcdf_lib(pre): inux-gnu/hdf5/serial;netcdf;hdf5_hl;hdf5;pthread;z;dl;m;curl
-- _netcdf_lib(post): inux-gnu/hdf5/serial;hdf5_hl;hdf5;pthread;z;dl;m;curl

And with this patch:

-- NETCDF_CONFIG_CFLAGS(pre): -I/usr/include -I/usr/include/hdf5/serial
-- _netcdf_dashI: -I/usr/include;-I/usr/include/hdf5/serial
-- _netcdf_includepath: /usr/include;/usr/include/hdf5/serial
-- _netcdf_cflags_other:  
-- NETCDF_CONFIG_LIBS(pre): -L/usr/lib -L/usr/lib/x86_64-linux-gnu/hdf5/serial -lnetcdf -lhdf5_hl -lhdf5 -lpthread -lz -ldl -lm -lcurl
-- _netcdf_dashl:  -lnetcdf; -lhdf5_hl; -lhdf5; -lpthread; -lz; -ldl; -lm; -lcurl
-- _netcdf_lib: netcdf;hdf5_hl;hdf5;pthread;z;dl;m;curl
-- _netcdf_dashL: -L/usr/lib;-L/usr/lib/x86_64-linux-gnu/hdf5/serial
-- _netcdf_libpath: /usr/lib;/usr/lib/x86_64-linux-gnu/hdf5/serial
-- NETCDF_CONFIG_CFLAGS(post): -I/usr/include -I/usr/include/hdf5/serial
-- NETCDF_CONFIG_LIBS(post): -L/usr/lib -L/usr/lib/x86_64-linux-gnu/hdf5/serial -lnetcdf -lhdf5_hl -lhdf5 -lpthread -lz -ldl -lm -lcurl
-- _netcdf_lib(pre): netcdf;hdf5_hl;hdf5;pthread;z;dl;m;curl
-- _netcdf_lib(post): hdf5_hl;hdf5;pthread;z;dl;m;curl

  1. I think the same should be done with the "-L", i.e.
    [...]

Applying the same change to the -I & -L regexes is a good idea, but not strictly required.

The include & libraries paths are much less likely to include "-I" or "-L" in their paths as is the case for "-l" in the Multi-Arch library path.

I've updated the patch to apply the change to the other regexes too.

#4 Updated by Remko over 1 year ago

  • Status changed from In Progress to Resolved

Fixed in r14773 thanks to patch by Bas.

#5 Updated by Paul over 1 year ago

  • Status changed from Resolved to Closed

Closed as fixed.

Also available in: Atom PDF