View Issue Details Jump to Notes ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0015737CMakeCMakepublic2015-09-11 13:162016-02-01 09:10
ReporterOrion Poplawski 
Assigned ToBrad King 
PriorityhighSeveritymajorReproducibilityalways
StatusclosedResolutionfixed 
PlatformLinuxOSFedoraOS Version23
Product VersionCMake 3.3.1 
Target VersionCMake 3.4Fixed in VersionCMake 3.4 
Summary0015737: Use of redhat-hardened-ld breaks CMake's Fortran compiler library detection for gfortran
DescriptionFedora is now compiling everything with hardened build options. However this is breaking CMake's fortran compiler information detection because it incorrectly picks the wrong link line:

Detecting Fortran compiler ABI info compiled with the following output:
Change Dir: /home/orion/fedora/psi4/psi4public-1881450f30d3bd2ac91dbc4fc6a4eaa5c9f03ae5/objdir-x86_64-redhat-linux-gnu/CMakeFiles/CMakeTmp

Run Build Command:"/usr/bin/gmake" "cmTC_41086/fast"
/usr/bin/gmake -f CMakeFiles/cmTC_41086.dir/build.make CMakeFiles/cmTC_41086.dir/build
gmake[1]: Entering directory '/home/orion/fedora/psi4/psi4public-1881450f30d3bd2ac91dbc4fc6a4eaa5c9f03ae5/objdir-x86_64-redhat-linux-gnu/CMakeFiles/CMakeTmp'
Building Fortran object CMakeFiles/cmTC_41086.dir/CMakeFortranCompilerABI.F.o
/usr/bin/gfortran -O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -m64 -mtune=generic -I/usr/lib64/gfortran/modules -c /usr/share/cmake/Modules/CMakeFortranCompilerABI.F -o CMakeFiles/cmTC_41086.dir/CMakeFortranCompilerABI.F.o
Linking Fortran executable cmTC_41086
/usr/bin/cmake -E cmake_link_script CMakeFiles/cmTC_41086.dir/link.txt --verbose=1
/usr/bin/gfortran -Wl,-z,relro -specs=/usr/lib/rpm/redhat/redhat-hardened-ld -v -O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -m64 -mtune=generic -I/usr/lib64/gfortran/modules CMakeFiles/cmTC_41086.dir/CMakeFortranCompilerABI.F.o -o cmTC_41086 -rdynamic
Driving: /usr/bin/gfortran -Wl,-z,relro -specs=/usr/lib/rpm/redhat/redhat-hardened-ld -v -O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -m64 -mtune=generic -I/usr/lib64/gfortran/modules CMakeFiles/cmTC_41086.dir/CMakeFortranCompilerABI.F.o -o cmTC_41086 -rdynamic -l gfortran -l m -shared-libgcc
Using built-in specs.
Reading specs from /usr/lib/rpm/redhat/redhat-hardened-ld
Reading specs from /usr/lib/rpm/redhat/redhat-hardened-cc1
COLLECT_GCC=/usr/bin/gfortran
COLLECT_LTO_WRAPPER=/usr/libexec/gcc/x86_64-redhat-linux/5.1.1/lto-wrapper
Target: x86_64-redhat-linux
Configured with: ../configure --enable-bootstrap --enable-languages=c,c++,objc,obj-c++,fortran,ada,go,lto --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --with-bugurl=http://bugzilla.redhat.com/bugzilla [^] --enable-shared --enable-threads=posix --enable-checking=release --enable-multilib --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-gnu-unique-object --enable-linker-build-id --with-linker-hash-style=gnu --enable-plugin --enable-initfini-array --disable-libgcj --with-isl --enable-libmpx --enable-gnu-indirect-function --with-tune=generic --with-arch_32=i686 --build=x86_64-redhat-linux
Thread model: posix
gcc version 5.1.1 20150618 (Red Hat 5.1.1-4) (GCC)
Reading specs from /usr/lib/gcc/x86_64-redhat-linux/5.1.1/libgfortran.spec
rename spec lib to liborig
COLLECT_GCC_OPTIONS='-specs=/usr/lib/rpm/redhat/redhat-hardened-ld' '-v' '-O2' '-g' '-pipe' '-Wall' '-Werror=format-security' '-fexceptions' '-fstack-protector-strong' '--param' 'ssp-buffer-size=4' '-grecord-gcc-switches' '-specs=/usr/lib/rpm/redhat/redhat-hardened-cc1' '-m64' '-mtune=generic' '-I' '/usr/lib64/gfortran/modules' '-o' 'cmTC_41086' '-rdynamic' '-shared-libgcc' '-march=x86-64' '-pie'
COMPILER_PATH=/usr/libexec/gcc/x86_64-redhat-linux/5.1.1/:/usr/libexec/gcc/x86_64-redhat-linux/5.1.1/:/usr/libexec/gcc/x86_64-redhat-linux/:/usr/lib/gcc/x86_64-redhat-linux/5.1.1/:/usr/lib/gcc/x86_64-redhat-linux/
LIBRARY_PATH=/usr/lib/gcc/x86_64-redhat-linux/5.1.1/:/usr/lib/gcc/x86_64-redhat-linux/5.1.1/../../../../lib64/:/lib/../lib64/:/usr/lib/../lib64/:/usr/lib/gcc/x86_64-redhat-linux/5.1.1/../../../:/lib/:/usr/lib/
COLLECT_GCC_OPTIONS='-specs=/usr/lib/rpm/redhat/redhat-hardened-ld' '-v' '-O2' '-g' '-pipe' '-Wall' '-Werror=format-security' '-fexceptions' '-fstack-protector-strong' '--param' 'ssp-buffer-size=4' '-grecord-gcc-switches' '-specs=/usr/lib/rpm/redhat/redhat-hardened-cc1' '-m64' '-mtune=generic' '-I' '/usr/lib64/gfortran/modules' '-o' 'cmTC_41086' '-rdynamic' '-shared-libgcc' '-march=x86-64' '-pie'
 /usr/libexec/gcc/x86_64-redhat-linux/5.1.1/collect2 -plugin /usr/libexec/gcc/x86_64-redhat-linux/5.1.1/liblto_plugin.so -plugin-opt=/usr/libexec/gcc/x86_64-redhat-linux/5.1.1/lto-wrapper -plugin-opt=-fresolution=/tmp/ccNzxFD8.res -plugin-opt=-pass-through=-lgcc_s -plugin-opt=-pass-through=-lgcc -plugin-opt=-pass-through=-lquadmath -plugin-opt=-pass-through=-lm -plugin-opt=-pass-through=-lgcc_s -plugin-opt=-pass-through=-lgcc -plugin-opt=-pass-through=-lc -plugin-opt=-pass-through=-lgcc_s -plugin-opt=-pass-through=-lgcc --build-id --no-add-needed --eh-frame-hdr --hash-style=gnu -m elf_x86_64 -export-dynamic -dynamic-linker /lib64/ld-linux-x86-64.so.2 -z now -pie -o cmTC_41086 /usr/lib/gcc/x86_64-redhat-linux/5.1.1/../../../../lib64/Scrt1.o /usr/lib/gcc/x86_64-redhat-linux/5.1.1/../../../../lib64/crti.o /usr/lib/gcc/x86_64-redhat-linux/5.1.1/crtbeginS.o -L/usr/lib/gcc/x86_64-redhat-linux/5.1.1 -L/usr/lib/gcc/x86_64-redhat-linux/5.1.1/../../../../lib64 -L/lib/../lib64 -L/usr/lib/../lib64 -L/usr/lib/gcc/x86_64-redhat-linux/5.1.1/../../.. -z relro CMakeFiles/cmTC_41086.dir/CMakeFortranCompilerABI.F.o -lgfortran -lm -lgcc_s -lgcc -lquadmath -lm -lgcc_s -lgcc -lc -lgcc_s -lgcc /usr/lib/gcc/x86_64-redhat-linux/5.1.1/crtendS.o /usr/lib/gcc/x86_64-redhat-linux/5.1.1/../../../../lib64/crtn.o
gmake[1]: Leaving directory '/home/orion/fedora/psi4/psi4public-1881450f30d3bd2ac91dbc4fc6a4eaa5c9f03ae5/objdir-x86_64-redhat-linux-gnu/CMakeFiles/CMakeTmp'


Parsed Fortran implicit link information from above output:
  link line regex: [^( *|.*[/\])(ld|([^/\]+-)?ld|collect2)[^/\]*( |$)]
  ignore line: [Change Dir: /home/orion/fedora/psi4/psi4public-1881450f30d3bd2ac91dbc4fc6a4eaa5c9f03ae5/objdir-x86_64-redhat-linux-gnu/CMakeFiles/CMakeTmp]
  ignore line: []
  ignore line: [Run Build Command:"/usr/bin/gmake" "cmTC_41086/fast"]
  ignore line: [/usr/bin/gmake -f CMakeFiles/cmTC_41086.dir/build.make CMakeFiles/cmTC_41086.dir/build]
  ignore line: [gmake[1]: Entering directory '/home/orion/fedora/psi4/psi4public-1881450f30d3bd2ac91dbc4fc6a4eaa5c9f03ae5/objdir-x86_64-redhat-linux-gnu/CMakeFiles/CMakeTmp']
  ignore line: [Building Fortran object CMakeFiles/cmTC_41086.dir/CMakeFortranCompilerABI.F.o]
  ignore line: [/usr/bin/gfortran -O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -m64 -mtune=generic -I/usr/lib64/gfortran/modules -c /usr/share/cmake/Modules/CMakeFortranCompilerABI.F -o CMakeFiles/cmTC_41086.dir/CMakeFortranCompilerABI.F.o]
  ignore line: [Linking Fortran executable cmTC_41086]
  ignore line: [/usr/bin/cmake -E cmake_link_script CMakeFiles/cmTC_41086.dir/link.txt --verbose=1]
  ignore line: [/usr/bin/gfortran -Wl,-z,relro -specs=/usr/lib/rpm/redhat/redhat-hardened-ld -v -O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -m64 -mtune=generic -I/usr/lib64/gfortran/modules CMakeFiles/cmTC_41086.dir/CMakeFortranCompilerABI.F.o -o cmTC_41086 -rdynamic ]
  ignore line: [Driving: /usr/bin/gfortran -Wl,-z,relro -specs=/usr/lib/rpm/redhat/redhat-hardened-ld -v -O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -m64 -mtune=generic -I/usr/lib64/gfortran/modules CMakeFiles/cmTC_41086.dir/CMakeFortranCompilerABI.F.o -o cmTC_41086 -rdynamic -l gfortran -l m -shared-libgcc]
  ignore line: [Using built-in specs.]
  ignore line: [Reading specs from /usr/lib/rpm/redhat/redhat-hardened-ld]
  ignore line: [Reading specs from /usr/lib/rpm/redhat/redhat-hardened-cc1]
  ignore line: [COLLECT_GCC=/usr/bin/gfortran]
  ignore line: [COLLECT_LTO_WRAPPER=/usr/libexec/gcc/x86_64-redhat-linux/5.1.1/lto-wrapper]
  ignore line: [Target: x86_64-redhat-linux]
  ignore line: [Configured with: ../configure --enable-bootstrap --enable-languages=c,c++,objc,obj-c++,fortran,ada,go,lto --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --with-bugurl=http://bugzilla.redhat.com/bugzilla [^] --enable-shared --enable-threads=posix --enable-checking=release --enable-multilib --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-gnu-unique-object --enable-linker-build-id --with-linker-hash-style=gnu --enable-plugin --enable-initfini-array --disable-libgcj --with-isl --enable-libmpx --enable-gnu-indirect-function --with-tune=generic --with-arch_32=i686 --build=x86_64-redhat-linux]
  ignore line: [Thread model: posix]
  ignore line: [gcc version 5.1.1 20150618 (Red Hat 5.1.1-4) (GCC) ]
  ignore line: [Reading specs from /usr/lib/gcc/x86_64-redhat-linux/5.1.1/libgfortran.spec]
  ignore line: [rename spec lib to liborig]
  link line: [COLLECT_GCC_OPTIONS='-specs=/usr/lib/rpm/redhat/redhat-hardened-ld' '-v' '-O2' '-g' '-pipe' '-Wall' '-Werror=format-security' '-fexceptions' '-fstack-protector-strong' '--param' 'ssp-buffer-size=4' '-grecord-gcc-switches' '-specs=/usr/lib/rpm/redhat/redhat-hardened-cc1' '-m64' '-mtune=generic' '-I' '/usr/lib64/gfortran/modules' '-o' 'cmTC_41086' '-rdynamic' '-shared-libgcc' '-march=x86-64' '-pie']
    arg [COLLECT_GCC_OPTIONS=-specs=/usr/lib/rpm/redhat/redhat-hardened-ld] ==> ignore
    arg [-v] ==> ignore
    arg [-O2] ==> ignore
    arg [-g] ==> ignore
    arg [-pipe] ==> ignore
    arg [-Wall] ==> ignore
    arg [-Werror=format-security] ==> ignore
    arg [-fexceptions] ==> ignore
    arg [-fstack-protector-strong] ==> ignore
    arg [--param] ==> ignore
    arg [ssp-buffer-size=4] ==> ignore
    arg [-grecord-gcc-switches] ==> ignore
    arg [-specs=/usr/lib/rpm/redhat/redhat-hardened-cc1] ==> ignore
    arg [-m64] ==> ignore
    arg [-mtune=generic] ==> ignore
    arg [-I] ==> ignore
    arg [/usr/lib64/gfortran/modules] ==> ignore
    arg [-o] ==> ignore
    arg [cmTC_41086] ==> ignore
    arg [-rdynamic] ==> ignore
    arg [-shared-libgcc] ==> ignore
    arg [-march=x86-64] ==> ignore
    arg [-pie] ==> ignore
  implicit libs: []
  implicit dirs: []
  implicit fwks: []
Steps To ReproduceCompile with LDFLAGS='-Wl,-z,relro -specs=/usr/lib/rpm/redhat/redhat-hardened-ld'
Additional Informationhttps://bugzilla.redhat.com/show_bug.cgi?id=1260490 [^]
TagsNo tags attached.
Attached Files

 Relationships
related to 0013960closedKitware Robot CMake does not always detect clang toolchain linker 

  Notes
(0039405)
Brad King (manager)
2015-09-11 13:32

The link line match regex is here:

 http://www.cmake.org/gitweb?p=cmake.git;a=blob;f=Modules/CMakeParseImplicitLinkInfo.cmake;hb=v3.3.1#l31 [^]

It needs to be pretty tolerant to pick up all kinds of link lines on many platforms. However, it needs to be taught not to match "-specs=/usr/lib/rpm/redhat/redhat-hardened-ld" as a linker. Currently it matches due to this change:

 Recognize ld with toolchain prefix
 http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=a2bc47df [^]
(0039406)
Brad King (manager)
2015-09-11 13:55

Actually we can just exclude lines like COLLECT_GCC_OPTIONS=... from consideration since they can never be the link line. This should fix it:

 CMakeParseImplicitLinkInfo: Do not match "VAR=..." as link line
 http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=97ffbcd8 [^]
(0039407)
Orion Poplawski (reporter)
2015-09-11 17:24

That appears to fix the issue we are seeing. Thank you for the quick response.
(0040395)
Robert Maynard (manager)
2016-02-01 09:10

Closing resolved issues that have not been updated in more than 4 months.

 Issue History
Date Modified Username Field Change
2015-09-11 13:16 Orion Poplawski New Issue
2015-09-11 13:32 Brad King Note Added: 0039405
2015-09-11 13:32 Brad King Relationship added related to 0013960
2015-09-11 13:55 Brad King Note Added: 0039406
2015-09-11 13:55 Brad King Assigned To => Brad King
2015-09-11 13:55 Brad King Status new => resolved
2015-09-11 13:55 Brad King Resolution open => fixed
2015-09-11 13:55 Brad King Fixed in Version => CMake 3.4
2015-09-11 13:55 Brad King Target Version => CMake 3.4
2015-09-11 17:24 Orion Poplawski Note Added: 0039407
2016-02-01 09:10 Robert Maynard Note Added: 0040395
2016-02-01 09:10 Robert Maynard Status resolved => closed


Copyright © 2000 - 2018 MantisBT Team