Failed to compile glibc 2.25 on Arch Linux - glibc

Background
I started a logic synthesis with Vivado 2020.2 on Arch Linux, and then got a segmentation fault.
The solution is to copy glibc 2.25 compiled with the "--disable-lock-elision" option into the Vivado directory.^1 ^2
I downloaded the source code from the Arch Linux repository and compiled it.
(I am sorry, but the following message contains some Japanese sentences. If you need to understand the meaning of this, please let me know.)
$ asp checkout glibc
$ cd glibc
$ git checkout e4db1c823e0d69073c7794671b1f4a68b984645c
$ cd trunk
$ vim PKGBUILD # Replace "--enable-lock-elision" to "--disable-lock-elision"
$ makepkg
...
../misc/syslog.c: 関数 ‘ __vsyslog_chk’ 内:
../misc/syslog.c:121:30: エラー: inlining failed in call to ‘ always_inline’ ‘ syslog’ : function not inlinable
121 | ldbl_strong_alias (__syslog, syslog)
|
...
This problem is caused by CFLAGS not being set properly.^3 Therefore I corrected the CFLAGS setting in the PKGBUILD and tried to compile again.
$ rm -rf pkg glibc src
$ vim PKGBUILD # Fix CFLAGS
$ makepkg
...
gcc -Wl,-O1,--sort-common,--as-needed,-z,relro,-z,now -shared -static-libgcc -Wl,-O1 -Wl,-z,defs -Wl,-dynamic-linker=/usr/lib/ld-linux-x86-64.so.2 -B/path/glibc/trunk/src/glibc-build/csu/ -Wl,--version-script=/path/to/glibc/trunk/src/glibc-build/libm.map -Wl,-soname=libm.so.6 -Wl,-z,combreloc -Wl,-z,relro -Wl,--hash-style=both -Wl,-z,now -L/path/to/glibc/trunk/src/glibc-build -L/path/to/glibc/trunk/src/glibc-build/math -L/path/to/glibc/trunk/src/glibc-build/elf -L/path/to/glibc/trunk/src/glibc-build/dlfcn -L/path/to/glibc/trunk/src/glibc-build/nss -L/path/to/glibc/trunk/src/glibc-build/nis -L/path/to/glibc/trunk/src/glibc-build/rt -L/path/to/glibc/trunk/src/glibc-build/resolv -L/path/to/glibc/trunk/src/glibc-build/crypt -L/path/to/glibc/trunk/src/glibc-build/mathvec -L/path/to/glibc/trunk/src/glibc-build/support -L/path/to/glibc/trunk/src/glibc-build/nptl -Wl,-rpath-link=/path/to/glibc/trunk/src/glibc-build:/path/to/glibc/trunk/src/glibc-build/math:/path/to/glibc/trunk/src/glibc-build/elf:/path/to/glibc/trunk/src/glibc-build/dlfcn:/path/to/glibc/trunk/src/glibc-build/nss:/path/to/glibc/trunk/src/glibc-build/nis:/path/to/glibc/trunk/src/glibc-build/rt:/path/to/glibc/trunk/src/glibc-build/resolv:/path/to/glibc/trunk/src/glibc-build/crypt:/path/to/glibc/trunk/src/glibc-build/mathvec:/path/to/glibc/trunk/src/glibc-build/support:/path/to/glibc/trunk/src/glibc-build/nptl -o /path/to/glibc/trunk/src/glibc-build/math/libm.so /path/to/glibc/trunk/src/glibc-build/csu/abi-note.o -Wl,--whole-archive /path/to/glibc/trunk/src/glibc-build/math/libm_pic.a -Wl,--no-whole-archive -Wl,--start-group /path/to/glibc/trunk/src/glibc-build/libc.so /path/to/glibc/trunk/src/glibc-build/libc_nonshared.a -Wl,--as-needed /path/to/glibc/trunk/src/glibc-build/elf/ld.so -Wl,--no-as-needed -Wl,--end-group
/usr/bin/ld: /usr/lib/gcc/x86_64-pc-linux-gnu/12.1.1/libgcc_eh.a(unwind-dw2-fde-dip.o): in function `_Unwind_Find_FDE':
(.text+0x1953): undefined reference to `_dl_find_object'
collect2: エラー: ld はステータス 1 で終了しました
make[2]: *** [../Makerules:582: /path/to/glibc/trunk/src/glibc-build/math/libm.so] エラー 1
make[2]: ディレクトリ '/path/to/glibc/trunk/src/glibc/math' から出ます
make[1]: *** [Makefile:215: math/others] エラー 2
make[1]: ディレクトリ '/path/to/glibc/trunk/src/glibc' から出ます
make: *** [Makefile:9: all] エラー 2
==> エラー: build() で問題が発生しました。
中止...
...
The linking failed here. The symbol _dl_find_object is not found.
Problem
I would like to compile glibc 2.25 completely, but it is failed because of the above problem. I do not know what I should do. Does anyone have any ideas?
The tools version
GCC
$ gcc --version
gcc (GCC) 12.1.1 20220730
Copyright (C) 2022 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
makepkg
$ makepkg --version
makepkg (pacman) 6.0.1
Copyright (c) 2006-2021 Pacman Development Team <pacman-dev#archlinux.org>.
Copyright (C) 2002-2006 Judd Vinet <jvinet#zeroflux.org>.
This is free software; see the source for copying conditions.
There is NO WARRANTY, to the extent permitted by law.
asp
$ asp --version
asp v8
PKGBUILD diff
diff --git a/trunk/PKGBUILD b/trunk/PKGBUILD
index 0fb6c73..5c5cb11 100644
--- a/trunk/PKGBUILD
+++ b/trunk/PKGBUILD
## -47,7 +47,7 ## build() {
echo "rootsbindir=/usr/bin" >> configparms
# remove fortify for building libraries
- CPPFLAGS=${CPPFLAGS/-D_FORTIFY_SOURCE=2/}
+ CFLAGS=${CFLAGS/-Wp,-D_FORTIFY_SOURCE=2/}
../${pkgname}/configure \
--prefix=/usr \
## -62,7 +62,7 ## build() {
--disable-profile \
--enable-stackguard-randomization \
--enable-stack-protector=strong \
- --enable-lock-elision \
+ --disable-lock-elision \
--enable-multi-arch \
--disable-werror

Related

Compiling OpenFOAM's scotch on macOS

I am trying to compile the scotch library embedded into the OpenFOAM.org third-party repository here. I ran the command
make -C ./ThirdParty-dev/scotch_6.0.9/src/
and I get the below error message:
(cd libscotch ; make VERSION=6 RELEASE=0 PATCHLEVEL=9 scotch && make install)
make \
CC="gcc" \
CCD="gcc" \
scotch.h \
scotchf.h \
libscotch.so \
libscotcherr.so \
libscotcherrexit.so
gcc -O3 -DCOMMON_FILE_COMPRESS_GZ -DCOMMON_RANDOM_FIXED_SEED -DSCOTCH_RENAME -Drestrict=__restrict -DSCOTCH_VERSION_NUM=6 -DSCOTCH_RELEASE_NUM=0 -DSCOTCH_PATCHLEVEL_NUM=9 dummysizes.c -o dummysizes -Xlinker --no-as-needed -lz -lm -lrt
ld: unknown option: --no-as-needed
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[2]: *** [dummysizes] Error 1
make[1]: *** [scotch] Error 2
make: *** [libscotch] Error 2
I am not sure what this error message means. If it is complaining about scotch not being available, that's why I'm compiling it in the first place. Out of desperation, I also tried to install it via brew install scotch to no avail. I would appreciate it if you could help me understand the above error message and resolve the issue.
The scotch build is a bit different in that they manage all of the OS/compiler-specific bits separately via a src/Makefile.inc that the user is responsible for providing. Of course they also provide a number of examples in the src/Make.inc/ directory, but they may not properly cover your particular OS/compiler requirements.
Since you grabbed the scotch source files from a third-party source instead of from the pristine upstream sources, you also have someone else's src/Makefile.inc that happens to be a Linux-specific version. So no surprise that it has incorrect link (or even compile) options.
The Darwin-specific makefile adjustments that are used by openfoam.com:
# Linux:
LIB = .so
ARFLAGS = $(WM_CFLAGS) -shared -o
LDFLAGS = -Xlinker --no-as-needed $(WM_LDFLAGS) -lm -lrt
# Darwin:
LIB = .dylib
ARFLAGS = $(WM_CFLAGS) -dynamiclib -undefined dynamic_lookup -o
LDFLAGS = $(WM_LDFLAGS) -lm
Without worrying about any other source of differences (in the OpenFOAM WM_CFLAGS and WM_LDFLAGS variables), it would appear that you are using Linux (gcc only?) link options for Darwin - so should be no surprise that they don't work.
The location for the pristine scotch sources move around a bit (seems to be related to their filer) but a reasonably uptodate reference is always included in the OpenFOAM ThirdParty BUILD.md. The URLs are provided as links, but also listed near the bottom of the file for easy grepping.
The current scotch link : https://gforge.inria.fr/frs/download.php/file/38352/scotch_6.1.0.tar.gz
The newest scotch is actually scotch-6.1.2 but there appears to be a regression in the dgraph calculation (the distributed graph in ptscotch) so probably better to stick with 6.1.0 for now.
Here is the information for the scotch repo itself (https://gitlab.inria.fr/scotch/scotch) - should be the most reliable source of information.

GCC with -march : invalid switch

OS: Ubuntu 16.04 s390x
Gcc: Build from source v7.3.0 using steps mentioned below:
mkdir gcc
cd gcc
wget https://ftpmirror.gnu.org/gcc/gcc-7.3.0/gcc-7.3.0.tar.xz
tar -xf gcc-7.3.0.tar.xz
cd gcc-7.3.0
./contrib/download_prerequisites
mkdir objdir
cd objdir
../configure --prefix=/opt/gcc --enable-languages=c,c++ --enable-shared --with-system-zlib --enable-threads=posix --enable-__cxa_atexit --enable-checking --enable-gnu-indirect-function --disable-bootstrap --disable-multilib
make
make install
ln -sf /opt/gcc/bin/gcc /usr/bin/gcc
ln -sf /opt/gcc/bin/g++ /usr/bin/g++
ln -sf /opt/gcc/bin/g++ /usr/bin/c++
export PATH=/opt/gcc/bin:"$PATH"
export LD_LIBRARY_PATH=/opt/gcc/lib64:"$LD_LIBRARY_PATH"
export C_INCLUDE_PATH=/opt/gcc/lib/gcc/s390x-linux-gnu/7.3.0/include
export CPLUS_INCLUDE_PATH=/opt/gcc/lib/gcc/s390x-linux-gnu/7.3.0/include
sudo ln -sf /opt/gcc/lib64/libstdc++.so.6.0.24 /usr/lib/s390x-linux-gnu/libstdc++.so.6
gcc --version
gcc (GCC) 7.3.0
Copyright (C) 2017 Free Software Foundation, Inc.
Then on compiling code for cockroachDB using make. Build fails with an error:
Error: invalid switch -march=z14
Error: unrecognized option -march=z14
Is there any flag which needs to enable here?
(No such error was observed if gcc is installed from repo using apt-get install g++-7 on Ubuntu 18.04)
-march-z14 was added after the GCC 7 release to GCC 8 in this commit and to GCC 7 in this commit. This commit went into the GCC 7.2 minor release, as far as I can tell, so GCC 7.3 should have it.
The error message is not a GCC error message, though. (Only code in the Ada front end calls command line option “switches”.) The build process uses something else from the Ubuntu 16.04 system which does not recognize -march=z14.
You may be able to use march=arch12 as a workaround. (The 12 refers to the edition of the Principles of Operation, which is currently off by two.)

c++11 std::unique_ptr error cmake 3.11.3 bootstrap

I am trying to bootstrap cmake 3.11.3 on Ubuntu 16.04.4 LTS xenial.
I have upgrade my gnu g++ compiler as follows:
> $ g++ --version
g++ (Ubuntu 8.1.0-5ubuntu1~16.04) 8.1.0 Copyright (C) 2018 Free
Software Foundation, Inc. This is free software; see the source for
copying conditions. There is NO warranty; not even for MERCHANTABILITY
or FITNESS FOR A PARTICULAR PURPOSE.
And manually re-pointed the symbolic links:
$ ll /usr/bin/*g++*
lrwxrwxrwx 1 root root 5 Jun 8 16:57 /usr/bin/g++ -> g++-8*
-rwxr-xr-x 1 root root 919832 Apr 24 15:02 /usr/bin/g++-5*
lrwxrwxrwx 1 root root 22 Jun 6 04:26 /usr/bin/g++-8 -> x86_64-linux-gnu-g++-8*
lrwxrwxrwx 1 root root 22 Jun 8 16:58 /usr/bin/x86_64-linux-gnu-g++ -> x86_64-linux-gnu-g++-8*
lrwxrwxrwx 1 root root 5 Apr 24 15:02 /usr/bin/x86_64-linux-gnu-g++-5 -> g++-5*
-rwxr-xr-x 1 root root 1071984 Jun 6 04:26 /usr/bin/x86_64-linux-gnu-g++-8*
However, I get the following error in the configuration of cmake:
$ sudo ./bootstrap
---------------------------------------------
CMake 3.11.3, Copyright 2000-2018 Kitware, Inc. and Contributors
Found GNU toolchain
C compiler on this system is: gcc
C++ compiler on this system is: g++
Makefile processor on this system is: make
g++ has setenv
g++ has unsetenv
g++ does not have environ in stdlib.h
g++ has stl wstring
g++ has <ext/stdio_filebuf.h>
---------------------------------------------
make: Warning: File 'Makefile' has modification time 2.3 s in the future
make: 'cmake' is up to date.
make: warning: Clock skew detected. Your build may be incomplete.
loading initial cache file /mnt/ganymede/user/gpeytavi/srv_admin/software/cmake-3.11.3/Bootstrap.cmk/InitialCacheFlags.cmake
CMake Error at CMakeLists.txt:92 (message):
The C++ compiler does not support C++11 (e.g. std::unique_ptr).
-- Configuring incomplete, errors occurred!
See also "/mnt/ganymede/user/gpeytavi/srv_admin/software/cmake-3.11.3/CMakeFiles/CMakeOutput.log".
See also "/mnt/ganymede/user/gpeytavi/srv_admin/software/cmake-3.11.3/CMakeFiles/CMakeError.log".
---------------------------------------------
Error when bootstrapping CMake:
Problem while running initial CMake
---------------------------------------------
Any idea why I get a c++11 std::unique_ptr non-compliant error?
In my case, the issue is because of the folder where I have CMake source code is in a mounted directory (in fact my entire rootfs is mounted over NFS)
So, I looked in 'mount' command output and selected '/run/user/1000' location as a local location as this is mounted using tmpfs and moved my CMake source code to this location.
with this, ./bootstrap && make && sudo make install executed successfully.
Actually the ./bootstrap script does try the different C++ standard flags with the compiler. So it should detect its capabilities automatically.
Please make sure you don't have any CXXFLAGS environment variable set and try from scratch again (the messages/warnings you get indicate several tries/errors in the same directory).
Output when Successful
As a reference on my Ubuntu calling CMake's ./bootstrap looks like this:
---------------------------------------------
CMake 3.11.20180423, Copyright 2000-2018 Kitware, Inc. and Contributors
Warning: This is an in-source build
Found GNU toolchain
C compiler on this system is: gcc
C++ compiler on this system is: g++ -std=gnu++1y
Makefile processor on this system is: make
g++ has setenv
g++ has unsetenv
g++ does not have environ in stdlib.h
g++ has stl wstring
g++ has <ext/stdio_filebuf.h>
---------------------------------------------
Debugging
For debugging your problem you also could:
Call ./bootstrap --verbose
Look into Bootstrap.cmk/cmake_bootstrap.log
Known Problem
I only once had a problem with bootstrap using clang compilers where I needed to do the following call:
export CXXFLAGS=-Xclang -std=c++1z -Xclang -stdlib=libc++
Alternative
If you just want to install the latest version see How to specify where CMake is installed in Ubuntu?
I was able to resolve the issue by ensuring that both the build machine and the NFS file server were synchronized by running ntpd on both.
For me it was clock skew. I use the below command :
date -s "2021-11-30 15:08:21"
to set the time to now for the server. Then it work, thanks...

The syntax of the command is incorrect while compiling Clang with GCC-4.9.1_x64

After coming across some problems regarding cmake and gcc-4.9.1 on windows system, and spending more than 2 hours of building llvm with clang I got a really nice error that I can't seem to find information on. I've done everything according to documentation and here's the story-teller error message that make gives me:
Scanning dependencies of target LTO_exports
[ 69%] Creating export file for LTO
The syntax of the command is incorrect.
make[2]: *** [tools/lto/LTO.def] Error 1
make[1]: *** [tools/lto/CMakeFiles/LTO_exports.dir/all] Error 2
make: *** [all] Error 2
That is all to it, no other detail available at all. I've checked the LTO.def file since it references that. The file contains one single entry: "EXPORTS[CR][LF]". The LTO_exports.dir/all contains the following files:
build.make
cmake_clean.cmake
depend.internal
depend.make
DependInfo.cmake
progress.make
I haven't touched these files at all. I used the following cmake command before actually using make.
C:\LLVM_Binaries>cmake -G"MinGW Makefiles" -DCMAKE_C_COMPILER="C:/MinGW/bin/gcc.exe" -DCMAKE_CXX_COMPILER="C:/MinGW/bin/g++.exe" -DCMAKE_MAKE_PROGRAM="C:/MinGW/bin/make.exe" -DCMAKE_BUILD_TYPE=Release ..\LLVM
Also here're the details of gcc g++ and make:
gcc --version
gcc (GCC) 4.9.1
Copyright (C) 2014 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
g++ --version
g++ (GCC) 4.9.1
Copyright (C) 2014 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
make -v
GNU Make 3.82
Built for x86_64-w64-mingw32
This program is built by Equation Solution <http://www.Equation.com>
for Windows.
Copyright (C) 2010 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Anyone else experienced this problem and managed to build llvm with clang on 64bit Windows operating system?
#Edit (output of make VERBOSE=1)
Scanning dependencies of target LTO_exports
make[2]: Leaving directory `C:/LLVM_Binaries'
make -f tools\lto\CMakeFiles\LTO_exports.dir\build.make tools/lto/CMakeFiles/LTO_exports.dir/build
make[2]: Entering directory `C:/LLVM_Binaries'
"C:\Program Files (x86)\CMake\bin\cmake.exe" -E cmake_progress_report C:\LLVM_Binaries\CMakeFiles
[ 69%] Creating export file for LTO
cd /d C:\LLVM_Binaries\tools\lto && "C:\Program Files (x86)\CMake\bin\cmake.exe" -E echo EXPORTS > LTO.def
cd /d C:\LLVM_Binaries\tools\lto && type C:/LLVM/tools/lto/lto.exports >> LTO.def
The syntax of the command is incorrect.
make[2]: *** [tools/lto/LTO.def] Error 1
make[2]: Leaving directory `C:/LLVM_Binaries'
make[1]: *** [tools/lto/CMakeFiles/LTO_exports.dir/all] Error 2
make[1]: Leaving directory `C:/LLVM_Binaries'
make: *** [all] Error 2
After digging in this issue quite deeply I've successfully built it. For anyone who might get this error while compiling llvm&clang on windows with gcc: http://reviews.llvm.org/D5476#5e5fbd1d
Of course you can avoid this problem by using the sources from their SVN instead of downloading the latest stable release from http://llvm.org/releases/download.html#3.5
Did you run the configuration file before running cmake?
sh ./configure
If that doesn't work, try using the 32 bit version of your compiler. If that works, you can build for 64-bit by compiling a GCC 32-bit cross compiler.
You could also try Cygwin - perhaps that might help. Or if you're really stuck you could go backtracking and run the problematic command from a terminal, not a makefile.

gfortran: error trying to exec 'f951': execvp: No such file or directory

I'm trying to compile a code found on the internet. Actually I'm trying to compile the code found at http://www.cs.berkeley.edu/~fowlkes/BSE/.
I tried to install gfortran and all the other libraries that are needed for compiling it in my MAC. But when I run the command make I get the following error:
$ make
(cd trlan && make -f Makefile.gcc)
gfortran -O3 -ffixed-line-length-132 -c dsort2.f
gfortran: error trying to exec 'f951': execvp: No such file or directory
make[1]: *** [dsort2.o] Error 1
make: *** [trlan/libtrlan.a] Error 2
I believed that the error is related to the version of my c++ compiler, that is not compatible with gfortran.
When I run the command gcc --version:
$ gcc --version
i686-apple-darwin11-llvm-gcc-4.2 (GCC) 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2336.11.00)
And when I run the command gfortran --version:
$ gfortran --version
GNU Fortran (GCC) 4.8.0 20120930 (experimental)
The Makefile under the directory that I'm running the command make is here: https://www.dropbox.com/s/q7mxvhnqg62ioum/Makefile.gcc
The Makefile under the directory trlan is here: https://www.dropbox.com/s/jydwpkg3f1upbgf/Makefile.gcc
Anyone has an idea of how to solve this problem or how to find tools that can help me solve it?
I'm trying this:
http://eftrunk.blogspot.com/2011/11/how-to-fix-error-trying-to-exec-f951.html
The simplest solution I found (perhaps not cleanest), is to statically link f951 in the path to the binary of gfortran:
find /usr/local/ -name f951
which for me returned:
/usr/local/gfortran/libexec/gcc/x86_64-apple-darwin11/4.6.2/f951
/usr/local/gfortran/libexec/gcc/x86_64-apple-darwin14/5.1.0/f951
so I put a link to the one that fits my system most closely in /usr/local/bin:
sudo ln -s /usr/local/gfortran/libexec/gcc/x86_64-apple-darwin14/5.1.0/f951 /usr/local/bin/.
And now gfortran works again. No need to uninstall XCode or any other exaggerated workload.
The answer can be found in the following website:
http://eftrunk.blogspot.com/2011/11/how-to-fix-error-trying-to-exec-f951.html
Basically it's necessary to delete Xcode, reinstall gcc and gfortran using http://hpc.sourceforge.net/ and then reinstall Xcode.

Resources