Skip to content

Enabling LTO (Was: p5.9.20210221.0: build fails) #2885

Closed
@kloczek

Description

@kloczek

Here is the begin on my build process in which I'm regenearing ac/am/lt files and executing condfigure::

+ cd ctags-p5.9.20210221.0
+ autoreconf -fiv
autoreconf: export WARNINGS=
autoreconf: Entering directory '.'
autoreconf: configure.ac: not using Gettext
autoreconf: running: aclocal --force -I m4
autoreconf: configure.ac: tracing
autoreconf: configure.ac: not using Libtool
autoreconf: configure.ac: not using Intltool
autoreconf: configure.ac: not using Gtkdoc
autoreconf: running: /usr/bin/autoconf --force
configure.ac:242: warning: The macro `AC_PROG_CC_C99' is obsolete.
configure.ac:242: You should run autoupdate.
./lib/autoconf/c.m4:1659: AC_PROG_CC_C99 is expanded from...
configure.ac:242: the top level
configure.ac:247: warning: The macro `AC_PROG_CC_C99' is obsolete.
configure.ac:247: You should run autoupdate.
./lib/autoconf/c.m4:1659: AC_PROG_CC_C99 is expanded from...
m4/ax_prog_cc_for_build.m4:38: AX_PROG_CC_FOR_BUILD is expanded from...
configure.ac:247: the top level
autoreconf: running: /usr/bin/autoheader --force
autoreconf: running: automake --add-missing --copy --force-missing
configure.ac:241: installing './compile'
configure.ac:35: installing './config.guess'
configure.ac:35: installing './config.sub'
configure.ac:28: installing './install-sh'
configure.ac:28: installing './missing'
Makefile.am: installing './depcomp'
/usr/share/automake-1.16/am/tags.am: warning: redefinition of 'ctags' ...
/usr/share/automake-1.16/am/program.am: ... 'ctags$(EXEEXT)' previously defined here
Makefile.am:38:   while processing program 'ctags'
autoreconf: './install-sh' is updated
autoreconf: './config.sub' is updated
autoreconf: './config.guess' is updated
autoreconf: Leaving directory '.'
+ CFLAGS='-O2 -g -grecord-gcc-switches -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -fstack-protector-strong -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -m64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -fdata-sections -ffunction-sections -flto=auto -flto-partition=none'
+ CXXFLAGS='-O2 -g -grecord-gcc-switches -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -fstack-protector-strong -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -m64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -fdata-sections -ffunction-sections -flto=auto -flto-partition=none'
+ FFLAGS='-O2 -g -grecord-gcc-switches -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -fstack-protector-strong -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -m64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -fdata-sections -ffunction-sections -flto=auto -flto-partition=none -I/usr/lib64/gfortran/modules'
+ FCFLAGS='-O2 -g -grecord-gcc-switches -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -fstack-protector-strong -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -m64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -fdata-sections -ffunction-sections -flto=auto -flto-partition=none -I/usr/lib64/gfortran/modules'
+ LDFLAGS='-Wl,-z,relro -Wl,--as-needed -Wl,--gc-sections -Wl,-z,now -specs=/usr/lib/rpm/redhat/redhat-hardened-ld -flto=auto -flto-partition=none -fuse-linker-plugin'
+ CC=/usr/bin/gcc
+ CXX=/usr/bin/g++
+ FC=/usr/bin/gfortran
+ AR=/usr/bin/gcc-ar
+ NM=/usr/bin/gcc-nm
+ RANLIB=/usr/bin/gcc-ranlib
+ export CFLAGS CXXFLAGS FFLAGS FCFLAGS LDFLAGS CC CXX FC AR NM RANLIB
+ ./configure --build=x86_64-redhat-linux-gnu --host=x86_64-redhat-linux-gnu --program-prefix= --disable-dependency-tracking --disable-silent-rules --prefix=/usr --exec-prefix=/usr --bindir=/usr/bin --sbindir=/usr/sbin --sysconfdir=/etc --datadir=/usr/share --includedir=/usr/include --libdir=/usr/lib64 --libexecdir=/usr/libexec --localstatedir=/var --sharedstatedir=/var/lib --mandir=/usr/share/man --infodir=/usr/share/info --enable-etags --enable-json --enable-seccomp --enable-xml --enable-yaml
Universal Ctags, version 5.9.0
Linux 5.10.6-200.fc33.x86_64 #1 SMP Mon Jan 11 20:05:21 UTC 2021 x86_64
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for a race-free mkdir -p... /usr/bin/mkdir -p
checking for gawk... gawk
checking whether make sets $(MAKE)... yes
checking whether make supports nested variables... yes
checking whether UID '1000' is supported by ustar format... yes
checking whether GID '1000' is supported by ustar format... yes
checking how to create a ustar tar archive... gnutar
checking whether make supports nested variables... (cached) yes
checking build system type... x86_64-redhat-linux-gnu
checking host system type... x86_64-redhat-linux-gnu
checking for x86_64-redhat-linux-gnu-gcc... /usr/bin/gcc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables...
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether the compiler supports GNU C... yes
checking whether /usr/bin/gcc accepts -g... yes
checking for /usr/bin/gcc option to enable C11 features... none needed
checking whether /usr/bin/gcc understands -c and -o together... yes
checking whether make supports the include directive... yes (GNU style)
checking dependency style of /usr/bin/gcc... none
checking for x86_64-redhat-linux-gnu-ranlib... /usr/bin/gcc-ranlib
checking for stdio.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for strings.h... yes
checking for sys/stat.h... yes
checking for sys/types.h... yes
checking for unistd.h... yes
checking whether byte ordering is bigendian... no
checking how to run the C preprocessor... /usr/bin/gcc -E
checking for x86_64-redhat-linux-gnu-gcc... no
checking for gcc... gcc
checking whether the compiler supports GNU C... yes
checking whether gcc accepts -g... yes
checking for gcc option to enable C11 features... (cached) none needed
checking whether gcc understands -c and -o together... yes
checking dependency style of gcc... none
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables...
checking whether we are cross compiling... no
checking for suffix of object files... o
checking how to run the C preprocessor... gcc -E
checking for cc for build... gcc
checking whether ln -s works... yes
checking for strip... strip
checking for special C compiler options needed for large files... no
checking for _FILE_OFFSET_BITS value needed for large files... no
checking for perl... no
checking for rst2man... /usr/bin/rst2man
checking whether rst2mn has --syntax-highlight option... yes
checking building in a git repository... no
checking for git... git
checking for timeout... timeout
checking for python3... python3
checking directory to use for temporary files... /tmp
checking for case-insensitive filenames... no
checking selected sort method... external sort utility
checking for sort... yes
checking if sort accepts our command line... yes
checking for direct.h... no
checking for dirent.h... yes
checking for fcntl.h... yes
checking for io.h... no
checking for stat.h... no
checking for types.h... no
checking for unistd.h... (cached) yes
checking for sys/dir.h... yes
checking for sys/stat.h... (cached) yes
checking for sys/types.h... (cached) yes
checking for sys/wait.h... yes
checking for grep that handles long lines and -e... /usr/bin/grep
checking for egrep... /usr/bin/grep -E
checking if L_tmpnam is defined in stdio.h... yes
checking for off_t... yes
checking for stdbool.h... yes
checking for an ANSI C-conforming const... yes
checking for typeof syntax and keyword spelling... typeof
checking if compiler supports statement expressions... yes
checking if struct stat contains st_ino... yes
checking for fnmatch... yes
checking for fnmatch.h... yes
checking for asprintf... yes
checking for strstr... yes
checking for strcasecmp... yes
checking for strncasecmp... yes
checking for mkstemp... yes
checking for opendir... yes
checking for strerror... yes
checking for truncate... yes
checking for setenv... yes
checking for regcomp... yes
checking if regcomp works... yes
checking for scandir... yes
checking for dirent.h... (cached) yes
checking for x86_64-redhat-linux-gnu-pkg-config... no
checking for pkg-config... /usr/bin/pkg-config
checking pkg-config is at least version 0.9.0... yes
checking for LIBXML... yes
checking for JANSSON... yes
checking for SECCOMP... yes
checking for LIBYAML... yes
configure: checking for new missing prototypes
checking for iconv_open or libiconv_open with -liconv... no
checking for iconv_open... yes
checking for /usr/bin/gcc options needed to detect all undeclared functions... none needed
checking whether __environ is declared... yes
checking whether _NSGetEnviron is declared... no
checking whether strnlen is declared... yes
checking whether strnlen is declared for build... yes
checking for mblen... yes
checking that generated files are newer than configure... done
configure: creating ./config.status
config.status: creating Makefile
config.status: creating man/ctags.1.rst
config.status: creating man/ctags-client-tools.7.rst
config.status: creating man/ctags-incompatibilities.7.rst
config.status: creating man/ctags-optlib.7.rst
config.status: creating man/ctags-faq.7.rst
config.status: creating man/ctags-lang-julia.7.rst
config.status: creating man/ctags-lang-python.7.rst
config.status: creating man/ctags-lang-verilog.7.rst
config.status: creating man/ctags-lang-inko.7.rst
config.status: creating man/ctags-lang-r.7.rst
config.status: creating man/readtags.1.rst
config.status: creating config.h
config.status: executing depfiles commands

Than at the end final linking fails:

/usr/bin/gcc -DHAVE_CONFIG_H -I.  -I. -I. -I./main -I./libreadtags -DREADTAGS_DSL -I./dsl    -Wall -O2 -g -grecord-gcc-switches -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -fstack-protector-strong -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -m64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -fdata-sections -ffunction-sections -flto=auto -flto-partition=none -c -o dsl/readtags-es.o `test -f 'dsl/es.c' || echo './'`dsl/es.c
make[1]: Leaving directory '/home/tkloczko/rpmbuild/BUILD/ctags-p5.9.20210221.0'
make[1]: Entering directory '/home/tkloczko/rpmbuild/BUILD/ctags-p5.9.20210221.0'
/usr/bin/rst2man --syntax-highlight=none man/ctags.1.rst man/ctags.1
make[1]: Leaving directory '/home/tkloczko/rpmbuild/BUILD/ctags-p5.9.20210221.0'
make[1]: Entering directory '/home/tkloczko/rpmbuild/BUILD/ctags-p5.9.20210221.0'
gcc -g -O2  -DUSE_SYSTEM_STRNLEN -Wl,-z,relro -Wl,--as-needed -Wl,--gc-sections -Wl,-z,now -specs=/usr/lib/rpm/redhat/redhat-hardened-ld -flto=auto -flto-partition=none -fuse-linker-plugin -o packcc ./misc/packcc/packcc.c
/usr/bin/ld: /tmp/ccXrfuA9.lto.o: relocation R_X86_64_32S against `.rodata' can not be used when making a PIE object; recompile with -fPIE
collect2: error: ld returned 1 exit status
make[1]: *** [Makefile:5896: packcc] Error 1
make[1]: Leaving directory '/home/tkloczko/rpmbuild/BUILD/ctags-p5.9.20210221.0'
make[1]: *** Waiting for unfinished jobs....
make[1]: Entering directory '/home/tkloczko/rpmbuild/BUILD/ctags-p5.9.20210221.0'
/usr/bin/gcc  -Wall -O2 -g -grecord-gcc-switches -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -fstack-protector-strong -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -m64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -fdata-sections -ffunction-sections -flto=auto -flto-partition=none  -Wl,-z,relro -Wl,--as-needed -Wl,--gc-sections -Wl,-z,now -specs=/usr/lib/rpm/redhat/redhat-hardened-ld -flto=auto -flto-partition=none -fuse-linker-plugin -o readtags libreadtags/readtags-readtags.o extra-cmds/readtags-printtags.o extra-cmds/readtags-readtags-cmd.o  dsl/readtags-es.o dsl/readtags-dsl.o dsl/readtags-qualifier.o dsl/readtags-sorter.o main/readtags-mio.o
make[1]: Leaving directory '/home/tkloczko/rpmbuild/BUILD/ctags-p5.9.20210221.0'
make: *** [Makefile:1359: all] Error 2

As you may see I'm passing to the configure env CC=/usr/bin/gcc however on final linking this $CC is not used because in configure.ac there are two compiler detectiom macros:

AC_PROG_CC                        << here
AC_PROG_CC_C99
AC_PROG_RANLIB
AC_C_BIGENDIAN

# https://www.gnu.org/software/autoconf-archive/ax_prog_cc_for_build.html
AX_PROG_CC_FOR_BUILD     << and here
[tkloczko@barrel ctags-p5.9.20210221.0]$ grep gcc Makefile
        main/dependency.h main/entry.h main/field.h main/gcc-attr.h \
CC = /usr/bin/gcc
CC_FOR_BUILD = gcc
CFLAGS = -O2 -g -grecord-gcc-switches -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -fstack-protector-strong -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -m64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -fdata-sections -ffunction-sections -flto=auto -flto-partition=none
CPP = /usr/bin/gcc -E
CPP_FOR_BUILD = gcc -E
RANLIB = /usr/bin/gcc-ranlib
ac_ct_CC_FOR_BUILD = gcc
        main/gcc-attr.h         \

[tkloczko@barrel ctags-p5.9.20210221.0]$ grep gcc Makefile
        main/dependency.h main/entry.h main/field.h main/gcc-attr.h \
CC = /usr/bin/gcc                    << here
CC_FOR_BUILD = gcc               << here
CFLAGS = -O2 -g -grecord-gcc-switches -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -fstack-protector-strong -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -m64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -fdata-sections -ffunction-sections -flto=auto -flto-partition=none
CPP = /usr/bin/gcc -E
CPP_FOR_BUILD = gcc -E
RANLIB = /usr/bin/gcc-ranlib
ac_ct_CC_FOR_BUILD = gcc                  << and here
        main/gcc-attr.h         \

Other small issies:

  • AC_PROG_RANLIB is already marked as obsoleted and LT_INIT should be used
  • instead using custom combination to build packetcc building that binaty should be put as noinst_PROGTRAM = packcc than it could be used and automake will guard to build packcc before it will be used and that binary will be not installed
  • at the moment is a bit strange taggin convention used like p<version>.<date> despite fact that in configure c is not changeing line:
AC_INIT([universal-ctags],[5.9.0])

Is it any reason why it is used that way? :P
Please consider use clear pattern for git tags which will match with what actially is used in AC_INIT

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions