why bazel not search system include paths - c++

The error is
.../demo.cc:5:10: fatal error: 'city.h' file not found
#include <city.h>
cityhash is installed by brew install cityhash.
city.h can be found in /usr/local/include.
And, it is actually in the search path of clang.
$ clang -E -xc++ - -v
Apple LLVM version 10.0.1 (clang-1001.0.46.3)
Target: x86_64-apple-darwin18.2.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin
"/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang" -cc1 -triple x86_64-apple-macosx10.14.0 -Wdeprecated-objc-isa-usage -Werror=deprecated-objc-isa-usage -E -disable-free -disable-llvm-verifier -discard-value-names -main-file-name - -mrelocation-model pic -pic-level 2 -mthread-model posix -mdisable-fp-elim -fno-strict-return -masm-verbose -munwind-tables -target-sdk-version=10.14 -target-cpu penryn -dwarf-column-info -debugger-tuning=lldb -target-linker-version 450.3 -v -resource-dir /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/10.0.1 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk -I/usr/local/include -stdlib=libc++ -Wno-atomic-implicit-seq-cst -Wno-framework-include-private-from-public -Wno-atimport-in-framework-header -Wno-quoted-include-in-framework-header -fdeprecated-macro -fdebug-compilation-dir /Users/formath/git/mlp -ferror-limit 19 -fmessage-length 202 -stack-protector 1 -fblocks -fencode-extended-block-signature -fregister-global-dtors-with-atexit -fobjc-runtime=macosx-10.14.0 -fcxx-exceptions -fexceptions -fmax-type-align=16 -fdiagnostics-show-option -fcolor-diagnostics -o - -x c++ -
clang -cc1 version 10.0.1 (clang-1001.0.46.3) default target x86_64-apple-darwin18.2.0
ignoring nonexistent directory "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/usr/include/c++/v1"
ignoring nonexistent directory "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/usr/local/include"
ignoring nonexistent directory "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/Library/Frameworks"
#include "..." search starts here:
#include <...> search starts here:
/usr/local/include
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/10.0.1/include
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/usr/include
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/System/Library/Frameworks (framework directory)
My Bazel version is 1.1.0.
I have saw a same question which is not fixed right now.
https://github.com/bazelbuild/bazel/issues/5391

As a workaround you could add a cc_library for a new_local_repository that wraps a view on /usr/local.
In your WORKSPACE file define a new_local_repository with the path attribute set to /usr/local and the build_file pointing to a BUILD file local to the workspace, for example:
# WORKSPACE
new_local_repository(
name = "usr_local",
path = "/usr/local",
build_file = "third_party/usr_local.BUILD",
)
The third_party/usr_local.BUILD file could have different rules for different libraries you want to wrap. For cityhash you could do something like this (I don't know the structure of the cityhash library, so I'm guessing here about the .so):
# third_party/usr_local.BUILD
cc_library(
name = "cityhash",
hdrs = glob(["include/cityhash/**"]),
srcs = [
"lib64/cityhash.so",
],
includes = [
"include/cityhash",
],
visibility = ["//visibility:public"],
)
Notice that the paths will be relative to the new local repository location (so in this case /usr/local).
Finally in your BUILD file you can reference the cityhash targetu using:
# BUILD
cc_binary(
name = "main",
srcs = [
"main.cc",
],
deps = [
"#usr_local//:cityhash",
],
)
Hope this helps.

Related

C++20 standard library compile error for module on macOS

Here are my test code and build scripts.
testmodule.cpp
#include <iostream>
export module testmodule;
export int add(int a, int b)
{
return a + b;
}
main.cpp
#include <iostream>
import testmodule;
using namespace std;
int main() {
cout << "Test Modules" << endl;
cout << "add 1 and 2 is " << add(1,2) << endl;
}
build.sh
rm *.o
rm *.pcm
clang++ -fmodules-ts -Wall -v -c -ferror-limit=1 -Xclang -emit-module-interface testmodule.cpp -o testmodule.pcm
clang++ -fmodules-ts -Wall -v -c -ferror-limit=1 -fprebuilt-module-path=. main.cpp -o main.o
clang++ -fmodules-ts -o main main.o *.pcm
When I run the build.sh, I got the following compile errors:
Apple clang version 14.0.0 (clang-1400.0.29.102)
Target: x86_64-apple-darwin21.6.0
Thread model: posix
InstalledDir: /Library/Developer/CommandLineTools/usr/bin
"/Library/Developer/CommandLineTools/usr/bin/clang" -cc1 -triple x86_64-apple-macosx12.0.0 -Wundef-prefix=TARGET_OS_ -Wdeprecated-objc-isa-usage -Werror=deprecated-objc-isa-usage -Werror=implicit-function-declaration -emit-obj -mrelax-all --mrelax-relocations -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name main.cpp -mrelocation-model pic -pic-level 2 -mframe-pointer=all -fno-strict-return -fno-rounding-math -funwind-tables=2 -target-sdk-version=12.3 -fvisibility-inlines-hidden-static-local-var -target-cpu penryn -tune-cpu generic -debugger-tuning=lldb -target-linker-version 819.6 -v -resource-dir /Library/Developer/CommandLineTools/usr/lib/clang/14.0.0 -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk -I/usr/local/include -stdlib=libc++ -internal-isystem /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1 -internal-isystem /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/local/include -internal-isystem /Library/Developer/CommandLineTools/usr/lib/clang/14.0.0/include -internal-externc-isystem /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include -internal-externc-isystem /Library/Developer/CommandLineTools/usr/include -Wall -Wno-reorder-init-list -Wno-implicit-int-float-conversion -Wno-c99-designator -Wno-final-dtor-non-final-class -Wno-extra-semi-stmt -Wno-misleading-indentation -Wno-quoted-include-in-framework-header -Wno-implicit-fallthrough -Wno-enum-enum-conversion -Wno-enum-float-conversion -Wno-elaborated-enum-base -Wno-reserved-identifier -Wno-gnu-folding-constant -Wno-cast-function-type -Wno-bitwise-instead-of-logical -fdeprecated-macro -fdebug-compilation-dir=/Users/bf/Workspaces/C-plus-plus-Playground/validateC++20 -ferror-limit 1 -stack-protector 1 -fstack-check -mdarwin-stkchk-strong-link -fblocks -fencode-extended-block-signature -fregister-global-dtors-with-atexit -fgnuc-version=4.2.1 -fno-cxx-modules -fmodules-ts -fno-implicit-modules -fprebuilt-module-path=. -fcxx-exceptions -fexceptions -fmax-type-align=16 -fcommon -fcolor-diagnostics -clang-vendor-feature=+messageToSelfInClassMethodIdReturnType -clang-vendor-feature=+disableInferNewAvailabilityFromInit -clang-vendor-feature=+disableNonDependentMemberExprInCurrentInstantiation -fno-odr-hash-protocols -clang-vendor-feature=+enableAggressiveVLAFolding -clang-vendor-feature=+revert09abecef7bbf -clang-vendor-feature=+thisNoAlignAttr -clang-vendor-feature=+thisNoNullAttr -mllvm -disable-aligned-alloc-awareness=1 -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o main.o -x c++ main.cpp
clang -cc1 version 14.0.0 (clang-1400.0.29.102) default target x86_64-apple-darwin21.6.0
ignoring nonexistent directory "/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/local/include"
ignoring nonexistent directory "/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/Library/Frameworks"
#include "..." search starts here:
#include <...> search starts here:
/usr/local/include
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1
/Library/Developer/CommandLineTools/usr/lib/clang/14.0.0/include
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include
/Library/Developer/CommandLineTools/usr/include
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Frameworks (framework directory)
End of search list.
In module 'testmodule' imported from main.cpp:3:
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/ostream:216:20: error: 'std::basic_ostream<char>::operator<<' from module 'testmodule.<global>' is not present in definition of 'std::ostream' provided earlier
basic_ostream& operator<<(nullptr_t)
^
If I comment out the line #1 in testmodule.cpp and run build.sh, I'll get a main binary as expected.
% ./main
Test Modules
add 1 and 2 is 3
It seems that I cannot include std libraries in both main.cpp and testmodule.cpp.
Any idea where I can start to look into this?
[Update 2022-10-18]
With Remy's suggestion, I tried import <iostream>; in testmodule.cpp, and got the following errors,
Apple clang version 14.0.0 (clang-1400.0.29.102)
Target: x86_64-apple-darwin21.6.0
Thread model: posix
InstalledDir: /Library/Developer/CommandLineTools/usr/bin
"/Library/Developer/CommandLineTools/usr/bin/clang" -cc1 -triple x86_64-apple-macosx12.0.0 -Wundef-prefix=TARGET_OS_ -Wdeprecated-objc-isa-usage -Werror=deprecated-objc-isa-usage -Werror=implicit-function-declaration -emit-obj -mrelax-all --mrelax-relocations -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name testmodule.cpp -mrelocation-model pic -pic-level 2 -mframe-pointer=all -fno-strict-return -fno-rounding-math -funwind-tables=2 -target-sdk-version=12.3 -fvisibility-inlines-hidden-static-local-var -target-cpu penryn -tune-cpu generic -debugger-tuning=lldb -target-linker-version 819.6 -v -resource-dir /Library/Developer/CommandLineTools/usr/lib/clang/14.0.0 -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk -I/usr/local/include -stdlib=libc++ -internal-isystem /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1 -internal-isystem /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/local/include -internal-isystem /Library/Developer/CommandLineTools/usr/lib/clang/14.0.0/include -internal-externc-isystem /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include -internal-externc-isystem /Library/Developer/CommandLineTools/usr/include -Wall -Wno-reorder-init-list -Wno-implicit-int-float-conversion -Wno-c99-designator -Wno-final-dtor-non-final-class -Wno-extra-semi-stmt -Wno-misleading-indentation -Wno-quoted-include-in-framework-header -Wno-implicit-fallthrough -Wno-enum-enum-conversion -Wno-enum-float-conversion -Wno-elaborated-enum-base -Wno-reserved-identifier -Wno-gnu-folding-constant -Wno-cast-function-type -Wno-bitwise-instead-of-logical -fdeprecated-macro -fdebug-compilation-dir=/Users/bf/Workspaces/C-plus-plus-Playground/validateC++20 -ferror-limit 1 -stack-protector 1 -fstack-check -mdarwin-stkchk-strong-link -fblocks -fencode-extended-block-signature -fregister-global-dtors-with-atexit -fgnuc-version=4.2.1 -fno-cxx-modules -fmodules-ts -fno-implicit-modules -fcxx-exceptions -fexceptions -fmax-type-align=16 -fcommon -fcolor-diagnostics -emit-module-interface -clang-vendor-feature=+messageToSelfInClassMethodIdReturnType -clang-vendor-feature=+disableInferNewAvailabilityFromInit -clang-vendor-feature=+disableNonDependentMemberExprInCurrentInstantiation -fno-odr-hash-protocols -clang-vendor-feature=+enableAggressiveVLAFolding -clang-vendor-feature=+revert09abecef7bbf -clang-vendor-feature=+thisNoAlignAttr -clang-vendor-feature=+thisNoNullAttr -mllvm -disable-aligned-alloc-awareness=1 -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o testmodule.pcm -x c++ testmodule.cpp
clang -cc1 version 14.0.0 (clang-1400.0.29.102) default target x86_64-apple-darwin21.6.0
ignoring nonexistent directory "/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/local/include"
ignoring nonexistent directory "/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/Library/Frameworks"
#include "..." search starts here:
#include <...> search starts here:
/usr/local/include
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1
/Library/Developer/CommandLineTools/usr/lib/clang/14.0.0/include
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include
/Library/Developer/CommandLineTools/usr/include
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Frameworks (framework directory)
End of search list.
testmodule.cpp:2:8: error: expected a module name after 'import'
import <iostream>;
^
[update Tue Oct 18 2:38PM]
Thanks for sigma's comments. I moved [export] section to the beginning of the code. I added cout statement in testmodule.cpp to make iostream required in testmodule.cpp. After the modification I still see compile errors when compile main.cpp
1 // testmodule.cpp
2 export module testmodule;
3 #include <iostream>
4 export int add(int a, int b)
5 {
6 std::cout << "in add()\n";
7 return a + b;
8 }
1 // main.cpp
2 #include <iostream>
3
4 import testmodule;
5
6 using namespace std;
7
8 int main() {
9 cout << "Test Modules" << endl;
10 cout << "add 1 and 2 is " << add(1,2) << endl;
11 }
% clang++ -fmodules-ts -Wall -c -ferror-limit=1 -Xclang -emit-module-interface testmodule.cpp -o testmodule.pcm
% clang++ -fmodules-ts -Wall -v -c -ferror-limit=1 -fprebuilt-module-path=. main.cpp -o main.o
Apple clang version 14.0.0 (clang-1400.0.29.102)
Target: x86_64-apple-darwin21.6.0
Thread model: posix
InstalledDir: /Library/Developer/CommandLineTools/usr/bin
"/Library/Developer/CommandLineTools/usr/bin/clang" -cc1 -triple x86_64-apple-macosx12.0.0 -Wundef-prefix=TARGET_OS_ -Wdeprecated-objc-isa-usage -Werror=deprecated-objc-isa-usage -Werror=implicit-function-declaration -emit-obj -mrelax-all --mrelax-relocations -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name main.cpp -mrelocation-model pic -pic-level 2 -mframe-pointer=all -fno-strict-return -fno-rounding-math -funwind-tables=2 -target-sdk-version=12.3 -fvisibility-inlines-hidden-static-local-var -target-cpu penryn -tune-cpu generic -debugger-tuning=lldb -target-linker-version 819.6 -v -resource-dir /Library/Developer/CommandLineTools/usr/lib/clang/14.0.0 -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk -I/usr/local/include -stdlib=libc++ -internal-isystem /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1 -internal-isystem /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/local/include -internal-isystem /Library/Developer/CommandLineTools/usr/lib/clang/14.0.0/include -internal-externc-isystem /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include -internal-externc-isystem /Library/Developer/CommandLineTools/usr/include -Wall -Wno-reorder-init-list -Wno-implicit-int-float-conversion -Wno-c99-designator -Wno-final-dtor-non-final-class -Wno-extra-semi-stmt -Wno-misleading-indentation -Wno-quoted-include-in-framework-header -Wno-implicit-fallthrough -Wno-enum-enum-conversion -Wno-enum-float-conversion -Wno-elaborated-enum-base -Wno-reserved-identifier -Wno-gnu-folding-constant -Wno-cast-function-type -Wno-bitwise-instead-of-logical -fdeprecated-macro -fdebug-compilation-dir=/Users/bf/Workspaces/C-plus-plus-Playground/validateC++20/try001 -ferror-limit 1 -stack-protector 1 -fstack-check -mdarwin-stkchk-strong-link -fblocks -fencode-extended-block-signature -fregister-global-dtors-with-atexit -fgnuc-version=4.2.1 -fno-cxx-modules -fmodules-ts -fno-implicit-modules -fprebuilt-module-path=. -fcxx-exceptions -fexceptions -fmax-type-align=16 -fcommon -fcolor-diagnostics -clang-vendor-feature=+messageToSelfInClassMethodIdReturnType -clang-vendor-feature=+disableInferNewAvailabilityFromInit -clang-vendor-feature=+disableNonDependentMemberExprInCurrentInstantiation -fno-odr-hash-protocols -clang-vendor-feature=+enableAggressiveVLAFolding -clang-vendor-feature=+revert09abecef7bbf -clang-vendor-feature=+thisNoAlignAttr -clang-vendor-feature=+thisNoNullAttr -mllvm -disable-aligned-alloc-awareness=1 -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o main.o -x c++ main.cpp
clang -cc1 version 14.0.0 (clang-1400.0.29.102) default target x86_64-apple-darwin21.6.0
ignoring nonexistent directory "/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/local/include"
ignoring nonexistent directory "/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/Library/Frameworks"
#include "..." search starts here:
#include <...> search starts here:
/usr/local/include
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1
/Library/Developer/CommandLineTools/usr/lib/clang/14.0.0/include
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include
/Library/Developer/CommandLineTools/usr/include
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Frameworks (framework directory)
End of search list.
In module 'testmodule' imported from main.cpp:3:
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/type_traits:436:43: error: 'std::integral_constant<bool, false>::value' from module 'testmodule' is not present in definition of 'std::integral_constant<bool, false>' provided earlier
static _LIBCPP_CONSTEXPR const _Tp value = __v;
^
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/type_traits:436:43: note: declaration of 'value' does not match
static _LIBCPP_CONSTEXPR const _Tp value = __v;
^
fatal error: too many errors emitted, stopping now [-ferror-limit=]
2 errors generated.
[update 2022-10-19]
Thanks sigma. I did some further tests on module fragment test. It seems the clang++ on macOS does not fully support c++ module.
Code,
// interface_part.cppm
export module M:interface_part;
export void World();
Compile command and output,
% clang++ -std=c++20 -fmodules-ts interface_part.cppm --precompile -o M-interface_part.pcm
interface_part.cppm:2:16: error: sorry, module partitions are not yet supported
export module M:interface_part;
^~~~~~~~~~~~~~~
1 error generated.

how to configure bazel toolchain for cross compile use rules_foreign_cc

my project need cross compile for arm aarch64 on ubuntu x86_64, but failed at configure stage, below is log
log
# Execution platform: //platforms:linux_gcc9_aarch64
SUBCOMMAND: # #boost//:filesystem [action 'Linking external/boost/libfilesystem.so', configuration: fc89852de14da3c51e8226c7c5e3087929e4f56710d05ed9ab86ed21b8eb16d4, execution platform: //platforms:linux_gcc9_aarch64]
(cd /root/.cache/bazel/_bazel_root/dbf178c3b436e7b271af34e78939cab5/execroot/bazel_simple_demo && \
exec env - \
PATH=/root/.cargo/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/usr/local/go/bin:/root/src/go/bin:/usr/local/jdk-11.0.15/bin:/root/.ft:/data/.cache/npm/global/bin \
PWD=/proc/self/cwd \
external/gcc9_arm_aarch64/bin/aarch64-none-linux-gnu-gcc -shared -o bazel-out/k8-fastbuild/bin/external/boost/libfilesystem.so bazel-out/k8-fastbuild/bin/external/boost/_objs/filesystem/codecvt_error_category.o bazel-out/k8-fastbuild/bin/external/boost/_objs/filesystem/directory.o bazel-out/k8-fastbuild/bin/external/boost/_objs/filesystem/exception.o bazel-out/k8-fastbuild/bin/external/boost/_objs/filesystem/operations.o bazel-out/k8-fastbuild/bin/external/boost/_objs/filesystem/path.o bazel-out/k8-fastbuild/bin/external/boost/_objs/filesystem/path_traits.o bazel-out/k8-fastbuild/bin/external/boost/_objs/filesystem/portability.o bazel-out/k8-fastbuild/bin/external/boost/_objs/filesystem/unique_path.o bazel-out/k8-fastbuild/bin/external/boost/_objs/filesystem/utf8_codecvt_facet.o bazel-out/k8-fastbuild/bin/external/boost/_objs/filesystem/windows_file_codecvt.o -Wl,-S -lstdc++ -lm -Wl,-no-as-needed -Wl,-z,relro,-z,now -Wall -pass-exit-codes '-fuse-ld=gold')
# Configuration: fc89852de14da3c51e8226c7c5e3087929e4f56710d05ed9ab86ed21b8eb16d4
# Execution platform: //platforms:linux_gcc9_aarch64
ERROR: /root/.cache/bazel/_bazel_root/dbf178c3b436e7b271af34e78939cab5/external/rules_foreign_cc/toolchains/BUILD.bazel:130:10: BootstrapGNUMake external/rules_foreign_cc/toolchains/make failed: (Exit 1): bash failed: error executing command
(cd /root/.cache/bazel/_bazel_root/dbf178c3b436e7b271af34e78939cab5/execroot/bazel_simple_demo && \
exec env - \
PATH=/root/.cargo/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/usr/local/go/bin:/root/src/go/bin:/usr/local/jdk-11.0.15/bin:/root/.ft:/data/.cache/npm/global/bin \
/bin/bash -c bazel-out/k8-opt-exec-277332AD/bin/external/rules_foreign_cc/toolchains/make_tool_foreign_cc/wrapper_build_script.sh)
# Configuration: 920514b75167e08aaf5b08b6fc5ff1721a7e3be841d2c442cd3624a15e568e52
# Execution platform: //platforms:linux_gcc9_aarch64
rules_foreign_cc: Build failed!
rules_foreign_cc: Keeping temp build directory and dependencies directory for debug.
rules_foreign_cc: Please note that the directories inside a sandbox are still cleaned unless you specify --sandbox_debug Bazel command line flag.
rules_foreign_cc: Printing build logs:
_____ BEGIN BUILD LOGS _____
+ AR=/root/.cache/bazel/_bazel_root/dbf178c3b436e7b271af34e78939cab5/execroot/bazel_simple_demo/external/gcc9_arm_aarch64/bin/aarch64-none-linux-gnu-gcc-ar
+ ARFLAGS=rcsD
+ CC=/root/.cache/bazel/_bazel_root/dbf178c3b436e7b271af34e78939cab5/execroot/bazel_simple_demo/external/gcc9_arm_aarch64/bin/aarch64-none-linux-gnu-gcc
+ CFLAGS='-fPIC -U_FORTIFY_SOURCE -fstack-protector -Wall -Wunused-but-set-parameter -Wno-free-nonheap-object -fno-omit-frame-pointer -march=armv8-a -g0 -O3 -DNDEBUG -D_FORTIFY_SOURCE=2 -ffunction-sections -fdata-sections -funsafe-math-optimizations -ftree-vectorize -std=c99 -no-canonical-prefixes -fno-canonical-system-headers -Wno-builtin-macro-redefined -D__DATE__=redacted -D__TIMESTAMP__=redacted -D__TIME__=redacted'
+ LD=/root/.cache/bazel/_bazel_root/dbf178c3b436e7b271af34e78939cab5/execroot/bazel_simple_demo/external/gcc9_arm_aarch64/bin/aarch64-none-linux-gnu-gcc
+ LDFLAGS='-lstdc++ -lm -Wl,-no-as-needed -Wl,-z,relro,-z,now -Wall -pass-exit-codes -fuse-ld=gold -Wl,--gc-sections'
+ ./configure --without-guile --with-guile=no --disable-dependency-tracking --prefix=/root/.cache/bazel/_bazel_root/dbf178c3b436e7b271af34e78939cab5/execroot/bazel_simple_demo/bazel-out/k8-opt-exec-277332AD/bin/external/rules_foreign_cc/toolchains/make
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for a thread-safe mkdir -p... /bin/mkdir -p
checking for gawk... gawk
checking whether make sets $(MAKE)... yes
checking whether make supports nested variables... yes
checking whether make supports the include directive... yes (GNU style)
checking for gcc... /root/.cache/bazel/_bazel_root/dbf178c3b436e7b271af34e78939cab5/execroot/bazel_simple_demo/external/gcc9_arm_aarch64/bin/aarch64-none-linux-gnu-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... configure: error: in `/root/.cache/bazel/_bazel_root/dbf178c3b436e7b271af34e78939cab5/execroot/bazel_simple_demo/bazel-out/k8-opt-exec-277332AD/bin/external/rules_foreign_cc/toolchains/make.build_tmpdir':
config.log
This file contains any messages produced by compilers while
running configure, to aid debugging if configure makes a mistake.
It was created by gperftools configure 2.9.1, which was
generated by GNU Autoconf 2.69. Invocation command line was
$ /root/.cache/bazel/_bazel_root/dbf178c3b436e7b271af34e78939cab5/execroot/bazel_simple_demo/external/com_github_gperftools_gperftools/configure --prefix=/root/.cache/bazel/_bazel_root/dbf178c3b436e7b271af34e78939cab5/execroot/bazel_simple_demo/bazel-out/k8-fastbuild/bin/external/com_github_gperftools_gperftools/gperftools_build.build_tmpdir/gperftools_build --enable-shared=no --enable-frame-pointers --disable-libunwind
## --------- ##
## Platform. ##
## --------- ##
hostname = ubuntu
uname -m = x86_64
uname -r = 5.4.0-109-generic
uname -s = Linux
uname -v = #123-Ubuntu SMP Fri Apr 8 09:10:54 UTC 2022
/usr/bin/uname -p = unknown
/bin/uname -X = unknown
/bin/arch = unknown
/usr/bin/arch -k = unknown
/usr/convex/getsysinfo = unknown
/usr/bin/hostinfo = unknown
/bin/machine = unknown
/usr/bin/oslevel = unknown
/bin/universe = unknown
PATH: /root/.cache/bazel/_bazel_root/dbf178c3b436e7b271af34e78939cab5/execroot/bazel_simple_demo/bazel-out/k8-fastbuild/bin/external/com_github_gperftools_gperftools/gperftools_build.ext_build_deps/bin
PATH: /root/.cache/bazel/_bazel_root/dbf178c3b436e7b271af34e78939cab5/execroot/bazel_simple_demo
PATH: /root/.cargo/bin
PATH: /usr/local/sbin
PATH: /usr/local/bin
PATH: /usr/sbin
PATH: /usr/bin
PATH: /sbin
PATH: /bin
PATH: /usr/games
PATH: /usr/local/games
PATH: /snap/bin
PATH: /usr/local/go/bin
PATH: /root/src/go/bin
PATH: /usr/local/jdk-11.0.15/bin
PATH: /root/.ft
PATH: /data/.cache/npm/global/bin
PATH: /root/.cache/bazel/_bazel_root/dbf178c3b436e7b271af34e78939cab5/execroot/bazel_simple_demo/bazel-out/k8-fastbuild/bin/external/com_github_gperftools_gperftools/gperftools_build.ext_build_deps/bin/toolchains
## ----------- ##
## Core tests. ##
## ----------- ##
configure:2617: checking build system type
configure:2631: result: x86_64-pc-linux-gnu
configure:2651: checking host system type
configure:2664: result: x86_64-pc-linux-gnu
configure:2700: checking for a BSD-compatible install
configure:2768: result: /usr/bin/install -c
configure:2779: checking whether build environment is sane
configure:2834: result: yes
configure:2978: checking for a thread-safe mkdir -p
configure:3017: result: /bin/mkdir -p
configure:3024: checking for gawk
configure:3040: found /usr/bin/gawk
configure:3051: result: gawk
configure:3062: checking whether /root/.cache/bazel/_bazel_root/dbf178c3b436e7b271af34e78939cab5/execroot/bazel_simple_demo/bazel-out/k8-opt-exec-2B5CBBC6/bin/external/rules_foreign_cc/toolchains/make/bin/make sets $(MAKE)
configure:3084: result: yes
configure:3113: checking whether /root/.cache/bazel/_bazel_root/dbf178c3b436e7b271af34e78939cab5/execroot/bazel_simple_demo/bazel-out/k8-opt-exec-2B5CBBC6/bin/external/rules_foreign_cc/toolchains/make/bin/make supports nested variables
configure:3130: result: yes
configure:3260: checking whether to enable maintainer-specific portions of Makefiles
configure:3269: result: no
configure:3296: checking for git
configure:3314: found /usr/local/bin/git
configure:3327: result: /usr/local/bin/git
configure:3400: checking whether /root/.cache/bazel/_bazel_root/dbf178c3b436e7b271af34e78939cab5/execroot/bazel_simple_demo/bazel-out/k8-opt-exec-2B5CBBC6/bin/external/rules_foreign_cc/toolchains/make/bin/make supports the include directive
configure:3415: /root/.cache/bazel/_bazel_root/dbf178c3b436e7b271af34e78939cab5/execroot/bazel_simple_demo/bazel-out/k8-opt-exec-2B5CBBC6/bin/external/rules_foreign_cc/toolchains/make/bin/make -f confmf.GNU && cat confinc.out
this is the am__doit target
configure:3418: $? = 0
configure:3437: result: yes (GNU style)
configure:3507: checking for gcc
configure:3534: result: /root/.cache/bazel/_bazel_root/dbf178c3b436e7b271af34e78939cab5/execroot/bazel_simple_demo/external/gcc9_arm_aarch64/bin/aarch64-none-linux-gnu-gcc
configure:3763: checking for C compiler version
configure:3772: /root/.cache/bazel/_bazel_root/dbf178c3b436e7b271af34e78939cab5/execroot/bazel_simple_demo/external/gcc9_arm_aarch64/bin/aarch64-none-linux-gnu-gcc --version >&5
aarch64-none-linux-gnu-gcc (GNU Toolchain for the A-profile Architecture 9.2-2019.12 (arm-9.10)) 9.2.1 20191025
Copyright (C) 2019 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.
configure:3783: $? = 0
configure:3772: /root/.cache/bazel/_bazel_root/dbf178c3b436e7b271af34e78939cab5/execroot/bazel_simple_demo/external/gcc9_arm_aarch64/bin/aarch64-none-linux-gnu-gcc -v >&5
Using built-in specs.
COLLECT_GCC=/root/.cache/bazel/_bazel_root/dbf178c3b436e7b271af34e78939cab5/execroot/bazel_simple_demo/external/gcc9_arm_aarch64/bin/aarch64-none-linux-gnu-gcc
COLLECT_LTO_WRAPPER=/root/.cache/bazel/_bazel_root/dbf178c3b436e7b271af34e78939cab5/external/gcc9_arm_aarch64/bin/../libexec/gcc/aarch64-none-linux-gnu/9.2.1/lto-wrapper
Target: aarch64-none-linux-gnu
Configured with: /tmp/dgboter/bbs/rhev-vm2--rhe6x86_64/buildbot/rhe6x86_64--aarch64-none-linux-gnu/build/src/gcc/configure --target=aarch64-none-linux-gnu --prefix= --with-sysroot=/aarch64-none-linux-gnu/libc --with-build-sysroot=/tmp/dgboter/bbs/rhev-vm2--rhe6x86_64/buildbot/rhe6x86_64--aarch64-none-linux-gnu/build/build-aarch64-none-linux-gnu/install//aarch64-none-linux-gnu/libc --with-bugurl=https://bugs.linaro.org/ --enable-gnu-indirect-function --enable-shared --disable-libssp --disable-libmudflap --enable-checking=release --enable-languages=c,c++,fortran --with-gmp=/tmp/dgboter/bbs/rhev-vm2--rhe6x86_64/buildbot/rhe6x86_64--aarch64-none-linux-gnu/build/build-aarch64-none-linux-gnu/host-tools --with-mpfr=/tmp/dgboter/bbs/rhev-vm2--rhe6x86_64/buildbot/rhe6x86_64--aarch64-none-linux-gnu/build/build-aarch64-none-linux-gnu/host-tools --with-mpc=/tmp/dgboter/bbs/rhev-vm2--rhe6x86_64/buildbot/rhe6x86_64--aarch64-none-linux-gnu/build/build-aarch64-none-linux-gnu/host-tools --with-isl=/tmp/dgboter/bbs/rhev-vm2--rhe6x86_64/buildbot/rhe6x86_64--aarch64-none-linux-gnu/build/build-aarch64-none-linux-gnu/host-tools --enable-fix-cortex-a53-843419 --with-pkgversion='GNU Toolchain for the A-profile Architecture 9.2-2019.12 (arm-9.10)'
Thread model: posix
gcc version 9.2.1 20191025 (GNU Toolchain for the A-profile Architecture 9.2-2019.12 (arm-9.10))
configure:3783: $? = 0
configure:3772: /root/.cache/bazel/_bazel_root/dbf178c3b436e7b271af34e78939cab5/execroot/bazel_simple_demo/external/gcc9_arm_aarch64/bin/aarch64-none-linux-gnu-gcc -V >&5
aarch64-none-linux-gnu-gcc: error: unrecognized command line option '-V'
aarch64-none-linux-gnu-gcc: fatal error: no input files
compilation terminated.
configure:3783: $? = 1
configure:3772: /root/.cache/bazel/_bazel_root/dbf178c3b436e7b271af34e78939cab5/execroot/bazel_simple_demo/external/gcc9_arm_aarch64/bin/aarch64-none-linux-gnu-gcc -qversion >&5
aarch64-none-linux-gnu-gcc: error: unrecognized command line option '-qversion'; did you mean '--version'?
aarch64-none-linux-gnu-gcc: fatal error: no input files
compilation terminated.
configure:3783: $? = 1
configure:3803: checking whether the C compiler works
configure:3825: /root/.cache/bazel/_bazel_root/dbf178c3b436e7b271af34e78939cab5/execroot/bazel_simple_demo/external/gcc9_arm_aarch64/bin/aarch64-none-linux-gnu-gcc -fPIC -U_FORTIFY_SOURCE -fstack-protector -Wall -Wunused-but-set-parameter -Wno-free-nonheap-object -fno-omit-frame-pointer -std=c99 -no-canonical-prefixes -fno-canonical-system-headers -Wno-builtin-macro-redefined -D__DATE__=redacted -D__TIMESTAMP__=redacted -D__TIME__=redacted -lstdc++ -lm -Wl,-no-as-needed -Wl,-z,relro,-z,now -Wall -pass-exit-codes -fuse-ld=gold -lpthread conftest.c >&5
configure:3829: $? = 0
configure:3877: result: yes
configure:3880: checking for C compiler default output file name
configure:3882: result: a.out
configure:3888: checking for suffix of executables
configure:3895: /root/.cache/bazel/_bazel_root/dbf178c3b436e7b271af34e78939cab5/execroot/bazel_simple_demo/external/gcc9_arm_aarch64/bin/aarch64-none-linux-gnu-gcc -o conftest -fPIC -U_FORTIFY_SOURCE -fstack-protector -Wall -Wunused-but-set-parameter -Wno-free-nonheap-object -fno-omit-frame-pointer -std=c99 -no-canonical-prefixes -fno-canonical-system-headers -Wno-builtin-macro-redefined -D__DATE__=redacted -D__TIMESTAMP__=redacted -D__TIME__=redacted -lstdc++ -lm -Wl,-no-as-needed -Wl,-z,relro,-z,now -Wall -pass-exit-codes -fuse-ld=gold -lpthread conftest.c >&5
configure:3899: $? = 0
configure:3921: result:
configure:3943: checking whether we are cross compiling
configure:3951: /root/.cache/bazel/_bazel_root/dbf178c3b436e7b271af34e78939cab5/execroot/bazel_simple_demo/external/gcc9_arm_aarch64/bin/aarch64-none-linux-gnu-gcc -o conftest -fPIC -U_FORTIFY_SOURCE -fstack-protector -Wall -Wunused-but-set-parameter -Wno-free-nonheap-object -fno-omit-frame-pointer -std=c99 -no-canonical-prefixes -fno-canonical-system-headers -Wno-builtin-macro-redefined -D__DATE__=redacted -D__TIMESTAMP__=redacted -D__TIME__=redacted -lstdc++ -lm -Wl,-no-as-needed -Wl,-z,relro,-z,now -Wall -pass-exit-codes -fuse-ld=gold -lpthread conftest.c >&5
configure:3955: $? = 0
configure:3962: ./conftest
/root/.cache/bazel/_bazel_root/dbf178c3b436e7b271af34e78939cab5/execroot/bazel_simple_demo/external/com_github_gperftools_gperftools/configure: line 3964: ./conftest: cannot execute binary file: Exec format error
configure:3966: $? = 126
configure:3973: error: in `/root/.cache/bazel/_bazel_root/dbf178c3b436e7b271af34e78939cab5/execroot/bazel_simple_demo/bazel-out/k8-fastbuild/bin/external/com_github_gperftools_gperftools/gperftools_build.build_tmpdir':
configure:3975: error: cannot run C compiled programs.
If you meant to cross compile, use `--host'.
See `config.log' for more details
bazel toolchain configuration:
toolchain:
http_archive(
name = "gcc9_arm_aarch64",
build_file = "#bazel_build_file_repo//bazel:gcc_arm_aarch64.BUILD",
sha256 = "8dfe681531f0bd04fb9c53cf3c0a3368c616aa85d48938eebe2b516376e06a66",
strip_prefix = "gcc-arm-9.2-2019.12-x86_64-aarch64-none-linux-gnu",
#urls = ["https://developer.arm.com/-/media/Files/downloads/gnu-a/9.2-2019.12/binrel/gcc-arm-9.2-2019.12-x86_64-aarch64-none-linux-gnu.tar.xz"],
urls = ["file:///root/src/cpp/toolchains/gcc-arm-9.2-2019.12-x86_64-aarch64-none-linux-gnu.tar.xz"],
)
platform config
constraint_setting(name = "gcc_version")
constraint_value(
name = "gcc_9",
constraint_setting = ":gcc_version",
)
constraint_value(
name = "gcc_10",
constraint_setting = ":gcc_version",
)
constraint_value(
name = "gcc_11",
constraint_setting = ":gcc_version",
)
platform(
name = "linux_gcc9_aarch64",
constraint_values = [
"#platforms//cpu:aarch64",
"#platforms//os:linux",
":gcc_9",
],
)
toolchain config
toolchain(
name = "gcc9_arm_aarch64_xcompile_toolchain",
exec_compatible_with = [
"#platforms//cpu:x86_64",
"#platforms//os:linux",
],
target_compatible_with = [
"#platforms//cpu:aarch64",
"#platforms//os:linux",
"//platforms:gcc_9",
],
toolchain = "#gcc9_arm_aarch64//:cc_toolchain",
toolchain_type = "#bazel_tools//tools/cpp:toolchain_type",
)
here is a very tiny demo to reproduce it:
[enter link description here][https://github.com/xiedeacc/bazel_simple_demo.git]

Tracing compiler error "undefined reference" when adding -lrt hasn't worked

Working on a large embedded linux codebase / SDK "Not Invented Here" - invented offshore by Elbonian Code Slaves nailing various things together.
Part of the codebase is Live555 WIS-Streamer. In order to (try to) fix a niggle relating to timestamps I have inserted a couple of calls to clock_gettime(CLOCK_MONOTONIC, &ts); which then caused the compilation to fail with several undefined reference to 'clock_gettime' errors.
I've had this before and it was solved by adding -lrt to the compiler options to include librealtime, however this time round it just isn't helping. I've done a lot of googling and reading SO but I can't see any definitive answer, and the makefiles for the project are a lot more complicated than the examples found across the web.
I need some help either pointing out the blindingly obvious mistake I've made in the makefile(s), or with tracing the compiler's expectations back through the chain to see where I need to make a change.
This project is cross-compiled using a set of libraries for the given hardware, so -lrt is still required (I see it's no longer necessary in later gcc libs) and we can't update or change that stuff easily.
Here's a snippet of failed compiler output, with much verbosity. I have shortened path names just to stay below the post size limit.
make[10]: Entering directory `/ipnc_rdk/ipnc_app/network/live/testProgs'
/ipnc_rdk/../dvsdk_ipnctools/linux-devkit//bin/arm-arago-linux-gnueabi-g++ -c -I../UsageEnvironment/include -I../groupsock/include -I../liveMedia/include -I../BasicUsageEnvironment/include -I. -O3 -v -DSOCKLEN_T=socklen_t -DNO_STRSTREAM=1 -D_LARGEFILE_SOURCE=1 -D_FILE_OFFSET_BITS=64 -Wl,--verbose -lrt -Wall -DBSD=1 testMP3Streamer.cpp
Using built-in specs.
Target: arm-arago-linux-gnueabi
Thread model: posix
gcc version 4.3.3 (GCC)
COLLECT_GCC_OPTIONS='-c' '-I../UsageEnvironment/include' '-I../groupsock/include' '-I../liveMedia/include' '-I../BasicUsageEnvironment/include' '-I.' '-O3' '-v' '-DSOCKLEN_T=socklen_t' '-DNO_STRSTREAM=1' '-D_LARGEFILE_SOURCE=1' '-D_FILE_OFFSET_BITS=64' '-Wall' '-DBSD=1' '-shared-libgcc' '-mfloat-abi=soft'
../libexec/gcc/arm-arago-linux-gnueabi/4.3.3/cc1plus -quiet -v -I../UsageEnvironment/include -I../groupsock/include -I../liveMedia/include -I../BasicUsageEnvironment/include -I. -iprefix ../lib/gcc/arm-arago-linux-gnueabi/4.3.3/ -isysroot ../arm-arago-linux-gnueabi -D_GNU_SOURCE -DSOCKLEN_T=socklen_t -DNO_STRSTREAM=1 -D_LARGEFILE_SOURCE=1 -D_FILE_OFFSET_BITS=64 -DBSD=1 testMP3Streamer.cpp -quiet -dumpbase testMP3Streamer.cpp -mfloat-abi=soft -auxbase testMP3Streamer -O3 -Wall -version -o /tmp/cckqq421.s
ignoring duplicate directory "../lib/gcc/../../lib/gcc/arm-arago-linux-gnueabi/4.3.3/../../../../arm-arago-linux-gnueabi/include/c++/4.3.3"
ignoring duplicate directory "../lib/gcc/../../lib/gcc/arm-arago-linux-gnueabi/4.3.3/../../../../arm-arago-linux-gnueabi/include/c++/4.3.3/arm-arago-linux-gnueabi"
ignoring duplicate directory "../lib/gcc/../../lib/gcc/arm-arago-linux-gnueabi/4.3.3/../../../../arm-arago-linux-gnueabi/include/c++/4.3.3/backward"
ignoring nonexistent directory "../arm-arago-linux-gnueabi/usr/local/include"
ignoring duplicate directory "../lib/gcc/../../lib/gcc/arm-arago-linux-gnueabi/4.3.3/include"
ignoring duplicate directory "../lib/gcc/../../lib/gcc/arm-arago-linux-gnueabi/4.3.3/include-fixed"
ignoring duplicate directory "../lib/gcc/../../lib/gcc/arm-arago-linux-gnueabi/4.3.3/../../../../arm-arago-linux-gnueabi/include"
#include "..." search starts here:
#include <...> search starts here:
../UsageEnvironment/include
../groupsock/include
../liveMedia/include
../BasicUsageEnvironment/include
.
../lib/gcc/arm-arago-linux-gnueabi/4.3.3/../../../../arm-arago-linux-gnueabi/include/c++/4.3.3
../lib/gcc/arm-arago-linux-gnueabi/4.3.3/../../../../arm-arago-linux-gnueabi/include/c++/4.3.3/arm-arago-linux-gnueabi
../lib/gcc/arm-arago-linux-gnueabi/4.3.3/../../../../arm-arago-linux-gnueabi/include/c++/4.3.3/backward
../lib/gcc/arm-arago-linux-gnueabi/4.3.3/include
../lib/gcc/arm-arago-linux-gnueabi/4.3.3/include-fixed
../lib/gcc/arm-arago-linux-gnueabi/4.3.3/../../../../arm-arago-linux-gnueabi/include
../arm-arago-linux-gnueabi/usr/include
End of search list.
GNU C++ (GCC) version 4.3.3 (arm-arago-linux-gnueabi)
compiled by GNU C version 4.4.3, GMP version 4.2.4, MPFR version 3.0.0-p7.
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
Compiler executable checksum: 05177eff49440274f3899a250a52b5a7
COLLECT_GCC_OPTIONS='-c' '-I../UsageEnvironment/include' '-I../groupsock/include' '-I../liveMedia/include' '-I../BasicUsageEnvironment/include' '-I.' '-O3' '-v' '-DSOCKLEN_T=socklen_t' '-DNO_STRSTREAM=1' '-D_LARGEFILE_SOURCE=1' '-D_FILE_OFFSET_BITS=64' '-Wall' '-DBSD=1' '-shared-libgcc' '-mfloat-abi=soft'
../lib/gcc/arm-arago-linux-gnueabi/4.3.3/../../../../arm-arago-linux-gnueabi/bin/as -mfloat-abi=soft -meabi=4 -o testMP3Streamer.o /tmp/cckqq421.s
COMPILER_PATH=../libexec/gcc/arm-arago-linux-gnueabi/4.3.3/:../libexec/gcc/:../lib/gcc/arm-arago-linux-gnueabi/4.3.3/../../../../arm-arago-linux-gnueabi/bin/
LIBRARY_PATH=../lib/gcc/arm-arago-linux-gnueabi/4.3.3/:../lib/gcc/:../lib/gcc/arm-arago-linux-gnueabi/4.3.3/../../../../arm-arago-linux-gnueabi/lib/:../arm-arago-linux-gnueabi/lib/:../arm-arago-linux-gnueabi/usr/lib/
COLLECT_GCC_OPTIONS='-c' '-I../UsageEnvironment/include' '-I../groupsock/include' '-I../liveMedia/include' '-I../BasicUsageEnvironment/include' '-I.' '-O3' '-v' '-DSOCKLEN_T=socklen_t' '-DNO_STRSTREAM=1' '-D_LARGEFILE_SOURCE=1' '-D_FILE_OFFSET_BITS=64' '-Wall' '-DBSD=1' '-shared-libgcc' '-mfloat-abi=soft'
/ipnc_rdk/../dvsdk_ipnctools/linux-devkit//bin/arm-arago-linux-gnueabi-g++ -otestMP3Streamer -L. testMP3Streamer.o ../liveMedia/libliveMedia.a ../groupsock/libgroupsock.a ../BasicUsageEnvironment/libBasicUsageEnvironment.a ../UsageEnvironment/libUsageEnvironment.a
../liveMedia/libliveMedia.a: In function `RTPSink::presetNextTimestamp()':
Locale.cpp:(.text+0x3232c): undefined reference to `clock_gettime'
../liveMedia/libliveMedia.a: In function `RTCPInstance::addSR()':
Locale.cpp:(.text+0x36dd8): undefined reference to `clock_gettime'
../BasicUsageEnvironment/libBasicUsageEnvironment.a: In function `TimeNow()':
BasicHashTable.cpp:(.text+0x1edc): undefined reference to `clock_gettime'
../BasicUsageEnvironment/libBasicUsageEnvironment.a: In function `DelayQueue::DelayQueue()':
BasicHashTable.cpp:(.text+0x2378): undefined reference to `clock_gettime'
../BasicUsageEnvironment/libBasicUsageEnvironment.a: In function `DelayQueue::DelayQueue()':
BasicHashTable.cpp:(.text+0x2414): undefined reference to `clock_gettime'
../BasicUsageEnvironment/libBasicUsageEnvironment.a:BasicHashTable.cpp:(.text+0x246c): more undefined references to `clock_gettime' follow
collect2: ld returned 1 exit status
make[10]: *** [testMP3Streamer] Error 1
Unfortunately I can't attach the full output or contents of the makefile as I seem to have hit the post length limit! Here is most of one of the makefiles, I have put ...snip... where I have cut out a lot of similar entries that you can probably guess what was going on:
INCLUDES = -Iinclude -I../UsageEnvironment/include -I../groupsock/include
PREFIX = /usr/local
LIBDIR = $(PREFIX)/lib
##### Change the following for your environment:
CROSS_COMPILE= $(MVTOOL_PREFIX)
COMPILE_OPTS = $(INCLUDES) -I. -v -Wall -O3 -DSOCKLEN_T=socklen_t -DNO_STRSTREAM=1 -D_LARGEFILE_SOURCE=1 -D_FILE_OFFSET_BITS=64 -Wl,--verbose -lrt
### JU - Added -lrt for MONOTONIC CLOCK in RTPSink.cpp
C = c
C_COMPILER = $(CROSS_COMPILE)gcc
C_FLAGS = $(COMPILE_OPTS)
CPP = cpp
CPLUSPLUS_COMPILER = $(CROSS_COMPILE)g++
CPLUSPLUS_FLAGS = $(COMPILE_OPTS) -DBSD=1
OBJ = o
LINK = $(CROSS_COMPILE)g++ -o
LINK_OPTS = -L.
CONSOLE_LINK_OPTS = $(LINK_OPTS)
LIBRARY_LINK = $(CROSS_COMPILE)ld -o
LIBRARY_LINK_OPTS = $(LINK_OPTS) -r -Bstatic
LIB_SUFFIX = a
LIBS_FOR_CONSOLE_APPLICATION =
LIBS_FOR_GUI_APPLICATION =
EXE =
##### End of variables to change
NAME = libliveMedia
LIVEMEDIA_LIB = $(NAME).$(LIB_SUFFIX)
ALL = $(LIVEMEDIA_LIB)
all: $(ALL)
.$(C).$(OBJ):
$(C_COMPILER) -c $(C_FLAGS) $<
.$(CPP).$(OBJ):
$(CPLUSPLUS_COMPILER) -c $(CPLUSPLUS_FLAGS) $<
MP3_SOURCE_OBJS = MP3FileSource.$(OBJ) ...snip... MP3InternalsHuffman.$(OBJ) MP3InternalsHuffmanTable.$(OBJ) MP3ADURTPSource.$(OBJ)
MPEG_SOURCE_OBJS = MPEG1or2Demux.$(OBJ) ...snip... ADTSAudioFileSource.$(OBJ)
H263_SOURCE_OBJS = H263plusVideoRTPSource.$(OBJ) H263plusVideoStreamFramer.$(OBJ) H263plusVideoStreamParser.$(OBJ)
AC3_SOURCE_OBJS = AC3AudioStreamFramer.$(OBJ) AC3AudioRTPSource.$(OBJ)
DV_SOURCE_OBJS = DVVideoStreamFramer.$(OBJ) DVVideoRTPSource.$(OBJ)
MP3_SINK_OBJS = MP3ADURTPSink.$(OBJ)
MPEG_SINK_OBJS = MPEG1or2AudioRTPSink.$(OBJ) $(MP3_SINK_OBJS) MPEG1or2VideoRTPSink.$(OBJ) MPEG4LATMAudioRTPSink.$(OBJ) MPEG4GenericRTPSink.$(OBJ) MPEG4ESVideoRTPSink.$(OBJ)
H263_SINK_OBJS = H263plusVideoRTPSink.$(OBJ)
H264_OR_5_SINK_OBJS = H264or5VideoRTPSink.$(OBJ) H264VideoRTPSink.$(OBJ) H265VideoRTPSink.$(OBJ)
DV_SINK_OBJS = DVVideoRTPSink.$(OBJ)
AC3_SINK_OBJS = AC3AudioRTPSink.$(OBJ)
MISC_SOURCE_OBJS = MediaSource.$(OBJ) ...snip... StreamReplicator.$(OBJ)
MISC_SINK_OBJS = MediaSink.$(OBJ) ...snip... OutputFile.$(OBJ)
MISC_FILTER_OBJS = uLawAudioFilter.$(OBJ)
TRANSPORT_STREAM_TRICK_PLAY_OBJS = MPEG2IndexFromTransportStream.$(OBJ) MPEG2TransportStreamIndexFile.$(OBJ) MPEG2TransportStreamTrickModeFilter.$(OBJ)
RTP_SOURCE_OBJS = RTPSource.$(OBJ) ...snip... VP9VideoRTPSource.$(OBJ)
RTP_SINK_OBJS = RTPSink.$(OBJ) MultiFramedRTPSink.$(OBJ) AudioRTPSink.$(OBJ) VideoRTPSink.$(OBJ) TextRTPSink.$(OBJ)
RTP_INTERFACE_OBJS = RTPInterface.$(OBJ)
RTP_OBJS = $(RTP_SOURCE_OBJS) $(RTP_SINK_OBJS) $(RTP_INTERFACE_OBJS)
RTCP_OBJS = RTCP.$(OBJ) rtcp_from_spec.$(OBJ)
GENERIC_MEDIA_SERVER_OBJS = GenericMediaServer.$(OBJ)
RTSP_OBJS = RTSPServer.$(OBJ) RTSPClient.$(OBJ) RTSPCommon.$(OBJ) RTSPServerSupportingHTTPStreaming.$(OBJ) RTSPRegisterSender.$(OBJ)
SIP_OBJS = SIPClient.$(OBJ)
SESSION_OBJS = MediaSession.$(OBJ) ...snip... ProxyServerMediaSession.$(OBJ)
QUICKTIME_OBJS = QuickTimeFileSink.$(OBJ) QuickTimeGenericRTPSource.$(OBJ)
AVI_OBJS = AVIFileSink.$(OBJ)
MATROSKA_FILE_OBJS = MatroskaFile.$(OBJ) MatroskaFileParser.$(OBJ) EBMLNumber.$(OBJ) MatroskaDemuxedTrack.$(OBJ)
MATROSKA_SERVER_MEDIA_SUBSESSION_OBJS = MatroskaFileServerMediaSubsession.$(OBJ) MP3AudioMatroskaFileServerMediaSubsession.$(OBJ)
MATROSKA_RTSP_SERVER_OBJS = MatroskaFileServerDemux.$(OBJ) $(MATROSKA_SERVER_MEDIA_SUBSESSION_OBJS)
MATROSKA_OBJS = $(MATROSKA_FILE_OBJS) $(MATROSKA_RTSP_SERVER_OBJS)
OGG_FILE_OBJS = OggFile.$(OBJ) OggFileParser.$(OBJ) OggDemuxedTrack.$(OBJ)
OGG_SERVER_MEDIA_SUBSESSION_OBJS = OggFileServerMediaSubsession.$(OBJ)
OGG_RTSP_SERVER_OBJS = OggFileServerDemux.$(OBJ) $(OGG_SERVER_MEDIA_SUBSESSION_OBJS)
OGG_OBJS = $(OGG_FILE_OBJS) $(OGG_RTSP_SERVER_OBJS)
MISC_OBJS = BitVector.$(OBJ) StreamParser.$(OBJ) DigestAuthentication.$(OBJ) ourMD5.$(OBJ) Base64.$(OBJ) Locale.$(OBJ)
LIVEMEDIA_LIB_OBJS = Media.$(OBJ) $(MISC_SOURCE_OBJS) $(MISC_SINK_OBJS) $(MISC_FILTER_OBJS) $(RTP_OBJS) $(RTCP_OBJS) $(GENERIC_MEDIA_SERVER_OBJS) $(RTSP_OBJS) $(SIP_OBJS) $(SESSION_OBJS) $(QUICKTIME_OBJS) $(AVI_OBJS) $(TRANSPORT_STREAM_TRICK_PLAY_OBJS) $(MATROSKA_OBJS) $(OGG_OBJS) $(MISC_OBJS)
$(LIVEMEDIA_LIB): $(LIVEMEDIA_LIB_OBJS) \
$(PLATFORM_SPECIFIC_LIB_OBJS)
$(LIBRARY_LINK)$# $(LIBRARY_LINK_OPTS) \
$(LIVEMEDIA_LIB_OBJS)
Media.$(CPP): include/Media.hh
include/Media.hh: include/liveMedia_version.hh
MediaSource.$(CPP): include/MediaSource.hh
include/MediaSource.hh: include/Media.hh
FramedSource.$(CPP): include/FramedSource.hh
include/FramedSource.hh: include/MediaSource.hh
...snip...
ourMD5.$(CPP): include/ourMD5.hh
Base64.$(CPP): include/Base64.hh
Locale.$(CPP): include/Locale.hh
include/liveMedia.hh:: include/MPEG1or2AudioRTPSink.hh ...snip... include/VP9VideoRTPSource.hh
include/liveMedia.hh:: include/MPEG2TransportStreamFromPESSource.hh ...snip... include/RTSPRegisterSender.hh
include/liveMedia.hh:: include/RTSPServerSupportingHTTPStreaming.hh ...snip... include/ProxyServerMediaSession.hh
clean:
-rm -rf *.$(OBJ) $(ALL) core *.core *~ include/*~
install: install1 $(INSTALL2)
install1: $(LIVEMEDIA_LIB)
install -d $(DESTDIR)$(PREFIX)/include/liveMedia $(DESTDIR)$(LIBDIR)
install -m 644 include/*.hh $(DESTDIR)$(PREFIX)/include/liveMedia
install -m 644 $(LIVEMEDIA_LIB) $(DESTDIR)$(LIBDIR)
install_shared_libraries: $(LIVEMEDIA_LIB)
ln -fs $(NAME).$(LIB_SUFFIX) $(DESTDIR)$(LIBDIR)/$(NAME).$(SHORT_LIB_SUFFIX)
ln -fs $(NAME).$(LIB_SUFFIX) $(DESTDIR)$(LIBDIR)/$(NAME).so
##### Any additional, platform-specific rules come here:
You have added -lrt - and apparently also -Wl,--verbose - to the
definition of COMPILE_OPTS. That will not work, because the $(COMPILE_OPTS)
are only passed to invocations of the compiler, and -lrt is a linker
option, which you must pass to the invocation of the linker for it have any
effect.
Remove -lrt from the definition of COMPILE_OPTS and add it to the
definition of LIBRARY_LINK_OPTS.
(The same applies to -Wl,--verbose, though you have probably only
introduced it for debugging. You clearly know that -Wl,option means
pass option through to the linker. But this instruction is addressed to
the gcc/g++ tool-driver and is effective when it is invoking the linker,
not when it is invoking the compiler. Hence you have verbose compiler output,
due to -v` option, but no verbose linker output).

std::terminate() linker error on a small clang project

I'm getting the following error on a project that links with clang (verbose output):
clang++ `/usr/local/Cellar/llvm/3.6.2/bin/llvm-config --cxxflags --ldflags --libs --system-libs` -lc++ -fno-rtti -o gen -lclangFrontendTool -lclangFrontend -lclangDriver -lclangSerialization -lclangCodeGen -lclangParse -lclangSema -lclangStaticAnalyzerFrontend -lclangStaticAnalyzerCheckers -lclangStaticAnalyzerCore -lclangAnalysis -lclangARCMigrate -lclangRewriteFrontend -lclangEdit -lclangAST -lclangLex -lclangBasic -I /usr/local/Cellar/llvm/3.6.2/include src/main.cpp -v
Apple LLVM version 7.0.2 (clang-700.1.81)
Target: x86_64-apple-darwin14.5.0
Thread model: posix
"/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang" -cc1 -triple x86_64-apple-macosx10.10.0 -Wdeprecated-objc-isa-usage -Werror=deprecated-objc-isa-usage -emit-obj -mrelax-all -disable-free -disable-llvm-verifier -main-file-name main.cpp -mrelocation-model pic -pic-level 2 -mthread-model posix -mdisable-fp-elim -masm-verbose -munwind-tables -target-cpu core2 -target-linker-version 253.9 -v -dwarf-column-info -resource-dir /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/clang/7.0.2 -D __STDC_CONSTANT_MACROS -D __STDC_FORMAT_MACROS -D __STDC_LIMIT_MACROS -I /usr/local/Cellar/llvm/3.6.2/include -I /usr/local/Cellar/llvm/3.6.2/include -stdlib=libc++ -Wall -W -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wmissing-field-initializers -Wno-long-long -Wcovered-switch-default -Wnon-virtual-dtor -pedantic -std=c++11 -fdeprecated-macro -fdebug-compilation-dir /Users/samvv/Projects/ffi-enhanced/xfi-gen -ferror-limit 19 -fmessage-length 142 -fvisibility-inlines-hidden -stack-protector 1 -mstackrealign -fblocks -fno-rtti -fobjc-runtime=macosx-10.10.0 -fencode-extended-block-signature -fcxx-exceptions -fexceptions -fmax-type-align=16 -fdiagnostics-show-option -fcolor-diagnostics -o /var/folders/9g/8c11l8090p524v5r7873yghc0000gn/T/main-918e82.o -x c++ src/main.cpp
clang -cc1 version 7.0.2 based upon LLVM 3.7.0svn default target x86_64-apple-darwin14.5.0
ignoring nonexistent directory "/usr/include/c++/v1"
ignoring duplicate directory "/usr/local/Cellar/llvm/3.6.2/include"
> #include "..." search starts here:
> #include <...> search starts here:
/usr/local/Cellar/llvm/3.6.2/include
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1
/usr/local/include
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/clang/7.0.2/include
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include
/usr/include
/System/Library/Frameworks (framework directory)
/Library/Frameworks (framework directory)
End of search list.
"/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ld" -demangle -dynamic -arch x86_64 -macosx_version_min 10.10.0 -o gen -L/usr/local/Cellar/llvm/3.6.2/lib -search_paths_first -headerpad_max_install_names -lLLVMLTO -lLLVMObjCARCOpts -lLLVMLinker -lLLVMBitWriter -lLLVMIRReader -lLLVMAsmParser -lLLVMXCoreDisassembler -lLLVMXCoreCodeGen -lLLVMXCoreDesc -lLLVMXCoreInfo -lLLVMXCoreAsmPrinter -lLLVMSystemZDisassembler -lLLVMSystemZCodeGen -lLLVMSystemZAsmParser -lLLVMSystemZDesc -lLLVMSystemZInfo -lLLVMSystemZAsmPrinter -lLLVMSparcDisassembler -lLLVMSparcCodeGen -lLLVMSparcAsmParser -lLLVMSparcDesc -lLLVMSparcInfo -lLLVMSparcAsmPrinter -lLLVMR600CodeGen -lLLVMipo -lLLVMVectorize -lLLVMR600AsmParser -lLLVMR600Desc -lLLVMR600Info -lLLVMR600AsmPrinter -lLLVMPowerPCDisassembler -lLLVMPowerPCCodeGen -lLLVMPowerPCAsmParser -lLLVMPowerPCDesc -lLLVMPowerPCInfo -lLLVMPowerPCAsmPrinter -lLLVMNVPTXCodeGen -lLLVMNVPTXDesc -lLLVMNVPTXInfo -lLLVMNVPTXAsmPrinter -lLLVMMSP430CodeGen -lLLVMMSP430Desc -lLLVMMSP430Info -lLLVMMSP430AsmPrinter -lLLVMMipsDisassembler -lLLVMMipsCodeGen -lLLVMMipsAsmParser -lLLVMMipsDesc -lLLVMMipsInfo -lLLVMMipsAsmPrinter -lLLVMHexagonDisassembler -lLLVMHexagonCodeGen -lLLVMHexagonDesc -lLLVMHexagonInfo -lLLVMCppBackendCodeGen -lLLVMCppBackendInfo -lLLVMARMDisassembler -lLLVMARMCodeGen -lLLVMARMAsmParser -lLLVMARMDesc -lLLVMARMInfo -lLLVMARMAsmPrinter -lLLVMAArch64Disassembler -lLLVMAArch64CodeGen -lLLVMAArch64AsmParser -lLLVMAArch64Desc -lLLVMAArch64Info -lLLVMAArch64AsmPrinter -lLLVMAArch64Utils -lLLVMTableGen -lLLVMDebugInfo -lLLVMOption -lLLVMX86Disassembler -lLLVMX86AsmParser -lLLVMX86CodeGen -lLLVMSelectionDAG -lLLVMAsmPrinter -lLLVMX86Desc -lLLVMMCDisassembler -lLLVMX86Info -lLLVMX86AsmPrinter -lLLVMX86Utils -lLLVMMCJIT -lLLVMLineEditor -lLLVMInstrumentation -lLLVMInterpreter -lLLVMExecutionEngine -lLLVMRuntimeDyld -lLLVMCodeGen -lLLVMScalarOpts -lLLVMProfileData -lLLVMObject -lLLVMMCParser -lLLVMBitReader -lLLVMInstCombine -lLLVMTransformUtils -lLLVMipa -lLLVMAnalysis -lLLVMTarget -lLLVMMC -lLLVMCore -lLLVMSupport -lcurses -lpthread -lz -lm -lc++ -lclangFrontendTool -lclangFrontend -lclangDriver -lclangSerialization -lclangCodeGen -lclangParse -lclangSema -lclangStaticAnalyzerFrontend -lclangStaticAnalyzerCheckers -lclangStaticAnalyzerCore -lclangAnalysis -lclangARCMigrate -lclangRewriteFrontend -lclangEdit -lclangAST -lclangLex -lclangBasic /var/folders/9g/8c11l8090p524v5r7873yghc0000gn/T/main-918e82.o -lc++ -lSystem /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/clang/7.0.2/lib/darwin/libclang_rt.osx.a
Undefined symbols for architecture x86_64:
"std::terminate()", referenced from:
___clang_call_terminate in main-918e82.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [all] Error 1
According to this question, linking with -lc++ should fix the issue, but in my case it doesn't. I've managed to reduce the issue down to this flag, which is added by llvm-config --ldflags:
-L/usr/local/Cellar/llvm/3.6.2/lib
Any idea why this flag is causing the error and how to fix it?
I found the problem: I was linking to non-default stdlibs using -L/usr/local/opt/llvm/lib/. By prepending -L/usr/lib, it made sure that OS X's default stdlib goes above the homebrewn version.

static compilation of proftpd on AIX

I'd like to compile proftpd on AIX to make it deployable on other server without having to reinstall all gnu lib library on each server.
I already manage to compile it dynamicaly, but I can't manage to get it compile with the option
LDFLAG="-Wl,-static"
like advise in the official proftpd documentation.
here the config.log error I get
This file contains any messages produced by compilers while
running configure, to aid debugging if configure makes a mistake.
It was created by configure, which was
generated by GNU Autoconf 2.61. Invocation command line was
$ ./configure LDFLAGS=-Wl,-static --with-modules=mod_tls:mod_sql:mod_sql_mysql:mod_sql_passwd:mod_sftp:mod_sftp_sql --without-getopt --enable-openssl --with-includes=/opt/freeware/include:/opt/freeware/include/mysql/mysql/:/home/poney2/src_proftpd/libmath_header/ --with-libraries=/opt/freeware/lib:/opt/freeware/lib/mysql/mysql/:/home/poney2/src_proftpd/libmath_lib --prefix=/home/poney/proftpd_bin --exec-prefix=/home/poney/proftpd_bin/proftpd
## --------- ##
## Platform. ##
## --------- ##
hostname = serverName
uname -m = 00C876004C00
uname -r = 1
uname -s = AIX
uname -v = 6
/usr/bin/uname -p = powerpc
/bin/uname -X = unknown
/bin/arch = unknown
/usr/bin/arch -k = unknown
/usr/convex/getsysinfo = unknown
/usr/bin/hostinfo = unknown
/bin/machine = unknown
/usr/bin/oslevel = 6.1.0.0
/bin/universe = unknown
PATH: /usr/bin
PATH: /etc
PATH: /usr/sbin
PATH: /usr/ucb
PATH: /home/poney/bin
PATH: /usr/bin/X11
PATH: /sbin
PATH: .
## ----------- ##
## Core tests. ##
## ----------- ##
configure:2122: checking build system type
configure:2140: result: powerpc-ibm-aix6.1.0.0
configure:2162: checking host system type
configure:2177: result: powerpc-ibm-aix6.1.0.0
configure:2199: checking target system type
configure:2214: result: powerpc-ibm-aix6.1.0.0
configure:2346: checking for gcc
configure:2362: found /usr/bin/gcc
configure:2373: result: gcc
configure:2611: checking for C compiler version
configure:2618: gcc --version >&5
gcc (GCC) 4.4.6
Copyright (C) 2010 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.
configure:2621: $? = 0
configure:2628: gcc -v >&5
Using built-in specs.
Target: powerpc-ibm-aix6.1.0.0
Configured with: ../gcc-4.4.6/configure --with-as=/usr/bin/as --with-ld=/usr/bin/ld --enable-languages=c,c++,fortran --prefix=/opt/freeware --enable-threads --enable-version-specific-runtime-libs --disable-nls --enable-decimal-float=dpd --host=powerpc-ibm-aix6.1.0.0
Thread model: aix
gcc version 4.4.6 (GCC)
configure:2631: $? = 0
configure:2638: gcc -V >&5
gcc: '-V' option must have argument
configure:2641: $? = 1
configure:2664: checking for C compiler default output file name
configure:2691: gcc -Wl,-static conftest.c >&5
ld: 0706-012 The -t flag is not recognized.
ld: 0706-012 The -a flag is not recognized.
ld: 0706-012 The -t flag is not recognized.
ld: 0706-027 The -i flag is ignored.
ld: 0706-012 The -c flag is not recognized.
collect2: ld returned 255 exit status
configure:2694: $? = 1
configure:2732: result:
configure: failed program was:
| /* confdefs.h. */
| #define PACKAGE_NAME ""
| #define PACKAGE_TARNAME ""
| #define PACKAGE_VERSION ""
| #define PACKAGE_STRING ""
| #define PACKAGE_BUGREPORT ""
| #define PR_BUILD_OPTS " 'LDFLAGS=-Wl,-static' '--with-modules=mod_tls:mod_sql:mod_sql_mysql:mod_sql_passwd:mod_sftp:mod_sftp_sql' '--without-getopt' '--enable-openssl' '--with-includes=/opt/freeware/include:/opt/freeware/include/mysql/mysql/:/home/poney2/src_proftpd/libmath_header/' '--with-libraries=/opt/freeware/lib:/opt/freeware/lib/mysql/mysql/:/home/poney2/src_proftpd/libmath_lib' '--prefix=/home/poney/proftpd_bin' '--exec-prefix=/home/poney/proftpd_bin/proftpd'"
| #define PR_PLATFORM "AIX6 (AIX6_1_0_0)"
| /* end confdefs.h. */
|
| int
| main ()
| {
|
| ;
| return 0;
| }
configure:2738: error: C compiler cannot create executables
See `config.log' for more details.
## ---------------- ##
## Cache variables. ##
## ---------------- ##
ac_cv_build=powerpc-ibm-aix6.1.0.0
ac_cv_env_CC_set=''
ac_cv_env_CC_value=''
ac_cv_env_CFLAGS_set=''
ac_cv_env_CFLAGS_value=''
ac_cv_env_CPPFLAGS_set=''
ac_cv_env_CPPFLAGS_value=''
ac_cv_env_CPP_set=''
ac_cv_env_CPP_value=''
ac_cv_env_LDFLAGS_set=set
ac_cv_env_LDFLAGS_value=-Wl,-static
ac_cv_env_LIBS_set=''
ac_cv_env_LIBS_value=''
ac_cv_env_build_alias_set=''
ac_cv_env_build_alias_value=''
ac_cv_env_host_alias_set=''
ac_cv_env_host_alias_value=''
ac_cv_env_target_alias_set=''
ac_cv_env_target_alias_value=''
ac_cv_host=powerpc-ibm-aix6.1.0.0
ac_cv_prog_ac_ct_CC=gcc
ac_cv_target=powerpc-ibm-aix6.1.0.0
## ----------------- ##
## Output variables. ##
## ----------------- ##
ADDL_CPPFLAGS=''
ADDL_DIRS=''
ALLOCA=''
AR=''
ARGZ_H=''
BINDIR=''
BUILD_SHARED_MODULE_OBJS=''
BUILD_STATIC_MODULE_ARCHIVES=''
BUILD_STATIC_MODULE_OBJS=''
CC='gcc'
CFLAGS=''
CONFIG_SHELL='/bin/sh'
CPP=''
CPPFLAGS=''
CURSES_LIBS=''
DATADIR=''
DEFS=''
DSYMUTIL=''
DUMPBIN=''
ECHO_C='ECHO_N=''
ECHO_T=''
EGREP=''
ENABLE_NLS=''
ENABLE_TESTS=''
EXEEXT=''
FGREP=''
GLUE_MODULE_OBJS=''
GREP=''
INCLTDL=''
INCLUDEDIR=''
INCLUDES=''
INSTALL_DATA=''
INSTALL_DEPS=''
INSTALL_PROGRAM=''
INSTALL_SCRIPT=''
INSTALL_STRIP=''
LD=''
LDFLAGS='-Wl,-static'
LIBADD_DL=''
LIBADD_DLD_LINK=''
LIBADD_DLOPEN=''
LIBADD_SHL_LOAD=''
LIBDIRS=''
LIBEXECDIR=''
LIBLTDL=''
LIBOBJS=''
LIBRARIES=''
LIBS=''
LIBTOOL=''
LIBTOOL_DEPS=''
LIB_DEPS=''
LIB_OBJS=''
LIPO=''
LN_S=''
LOCALSTATEDIR=''
LTDLDEPS=''
LTDLINCL=''
LTDLOPEN=''
LTLIBOBJS=''
LT_CONFIG_H=''
LT_DLLOADERS=''
LT_DLPREOPEN=''
MAIN_LDFLAGS=''
MAIN_LIBS=''
MODULE_DEPS=''
MODULE_LDFLAGS=''
NM=''
NMEDIT=''
OBJDUMP=''
OBJEXT=''
OSREL='-DAIX6_1_0_0'
OSTYPE='-DAIX6'
OTOOL64=''
OTOOL=''
PACKAGE_BUGREPORT=''
PACKAGE_NAME=''
PACKAGE_STRING=''
PACKAGE_TARNAME=''
PACKAGE_VERSION=''
PATH_SEPARATOR=':'
PREFIX=''
RANLIB=''
SBINDIR=''
SED=''
SET_MAKE=''
SHARED_MODULE_DIRS=''
SHARED_MODULE_LIBS=''
SHARED_MODULE_OBJS=''
SHELL='/bin/sh'
STATIC_MODULE_DIRS=''
STATIC_MODULE_OBJS=''
STRIP=''
SYSCONFDIR=''
UTILS_LIBS=''
VERSION=''
ac_ct_CC='gcc'
ac_ct_DUMPBIN=''
bindir='${exec_prefix}/bin'
build='powerpc-ibm-aix6.1.0.0'
build_alias=''
build_cpu='powerpc'
build_os='aix6.1.0.0'
build_vendor='ibm'
datadir='${datarootdir}'
datarootdir='${prefix}/share'
docdir='${datarootdir}/doc/${PACKAGE}'
dvidir='${docdir}'
exec_prefix='/home/poney/proftpd_bin/proftpd'
host='powerpc-ibm-aix6.1.0.0'
host_alias=''
host_cpu='powerpc'
host_os='aix6.1.0.0'
host_vendor='ibm'
htmldir='${docdir}'
includedir='${prefix}/include'
infodir='${datarootdir}/info'
install_group=''
install_user=''
libdir='${exec_prefix}/lib'
libexecdir='${exec_prefix}/libexec'
localedir='${datarootdir}/locale'
localstatedir='${prefix}/var'
lt_ECHO='print -r'
ltdl_LIBOBJS=''
ltdl_LTLIBOBJS=''
mandir='${datarootdir}/man'
oldincludedir='/usr/include'
pdfdir='${docdir}'
pkgconfigdir=''
prefix='/home/poney/proftpd_bin'
program_transform_name='s,x,x,'
psdir='${docdir}'
sbindir='${exec_prefix}/sbin'
sharedstatedir='${prefix}/com'
subdirs=''
sys_symbol_underscore=''
sysconfdir='${prefix}/etc'
target='powerpc-ibm-aix6.1.0.0'
target_alias=''
target_cpu='powerpc'
target_os='aix6.1.0.0'
target_vendor='ibm'
## ----------- ##
## confdefs.h. ##
## ----------- ##
#define PACKAGE_NAME ""
#define PACKAGE_TARNAME ""
#define PACKAGE_VERSION ""
#define PACKAGE_STRING ""
#define PACKAGE_BUGREPORT ""
#define PR_BUILD_OPTS " 'LDFLAGS=-Wl,-static' '--with-modules=mod_tls:mod_sql:mod_sql_mysql:mod_sql_passwd:mod_sftp:mod_sftp_sql' '--without-getopt' '--enable-openssl' '--with-includes=/opt/freeware/include:/opt/freeware/include/mysql/mysql/:/home/poney2/src_proftpd/libmath_header/' '--with-libraries=/opt/freeware/lib:/opt/freeware/lib/mysql/mysql/:/home/poney2/src_proftpd/libmath_lib' '--prefix=/home/poney/proftpd_bin' '--exec-prefix=/home/poney/proftpd_bin/proftpd'"
#define PR_PLATFORM "AIX6 (AIX6_1_0_0)"
PS: I already try -Bstatic -all-static and -static flags but they are ignored.
Possible answer
Part of solution for me is modyfing the libpath to add a folder to this where I will put all the lib to pack it as a tar file and deploy the proftpd installation folder with the lib inside, it's not clean but it does work:
LDFLAGS="-Wl,-blibpath:/a/new/lib/path"
I do not validate my answer as it's not the real answer but that could help some of you.
PS: Please take into account that this is working with IBM XL C Compiler and should work on GCC as well
The output of the configure script shows:
configure:2691: gcc -Wl,-static conftest.c >&5
ld: 0706-012 The -t flag is not recognized.
ld: 0706-012 The -a flag is not recognized.
ld: 0706-012 The -t flag is not recognized.
ld: 0706-027 The -i flag is ignored.
ld: 0706-012 The -c flag is not recognized.
collect2: ld returned 255 exit status
This indicates that the -Wl option is successfully passing the option to ld, but ld does not recognize the option. As you're using AIX ld, it requires using -dn along with -bsvr4 with the link line, so, for example the flags option should read -Wl,-bsvr4 -Wl,-dn.
There is a note at the end of the man page for ld on AIX which states that:
The application can also have to be linked again whenever an updated release of the operating system is installed. Any application that is statically linked is not binary portable from any fix or release level to any other fix or release level.
Depending on the complexity of the final link line for proftpd, you can use the options -bstatic and -bdynamic to prompt the loading of static libraries for specific items; so in my case my final link line looked like:
gcc -o proftpd <lots of .o files> -L/home/user/Development/experiments/proftpd-1.3.4d/lib -lsupp -lcrypt -ldl -L/home/user/Development/experiments/proftpd-1.3.4d/lib/libcap -lcap -lpam
Now in this case, it means that it depends on libcrypt, which isn't a default shipped library, so I rejig the link line so that it has the -lcrypt wrapped:
-Wl,-bstatic -lcrypt -Wl,-bdynamic
and now it links with the static version of the crypt library, and no longer mentions it as part of the run-time link dependencies.
As an addenda to this, you should only static link the libraries that aren't shipped by default on the OS in question, and I note that proftpd supports dynamically loading modules, which means that you should only statically link the required modules.
In general, though, if you're building to deploy on another system, I would advise creating static-only copies of the dependent libraries that you're using and explicitly pass them into the configure options. This keeps the build environment clean from the run-time environment.
Can you try using only "-static" instead of "-Wl,-static"?