i2pd icon indicating copy to clipboard operation
i2pd copied to clipboard

PowerPC: i2pd fails with Bus error if built using GCC atomics

Open barracuda156 opened this issue 2 years ago • 143 comments

I have tried building i2pd for ppc on 10.6.8 with gcc11, and it failed on this:

[ 75%] Building CXX object CMakeFiles/libi2pd.dir/Users/svacchanda/i2pd/libi2pd/util.cpp.o
/Users/svacchanda/i2pd/libi2pd/util.cpp: In function ‘void i2p::util::SetThreadName(const char*)’:
/Users/svacchanda/i2pd/libi2pd/util.cpp:127:36: error: invalid conversion from const char*’ to ‘char*’ [-fpermissive]
  127 |                 pthread_setname_np(name);
      |                                    ^~~~
      |                                    |
      |                                    const char*
In file included from /opt/svacchanda/gcc11ppc/include/c++/11.2.1/powerpc-apple-darwin10/bits/gthr-default.h:35,
                 from /opt/svacchanda/gcc11ppc/include/c++/11.2.1/powerpc-apple-darwin10/bits/gthr.h:148,
                 from /opt/svacchanda/gcc11ppc/include/c++/11.2.1/ext/atomicity.h:35,
                 from /opt/svacchanda/gcc11ppc/include/c++/11.2.1/bits/basic_string.h:39,
                 from /opt/svacchanda/gcc11ppc/include/c++/11.2.1/string:55,
                 from /Users/svacchanda/i2pd/libi2pd/util.cpp:10:
/Developer/SDKs/MacOSX10.6.sdk/usr/include/pthread.h:361:36: note:   initializing argument 1 of ‘int pthread_setname_np(char*)’
  361 | int             pthread_setname_np(char*);
      |                                    ^~~~~
make[2]: *** [CMakeFiles/libi2pd.dir/Users/svacchanda/i2pd/libi2pd/util.cpp.o] Error 1
make[2]: *** Waiting for unfinished jobs....
make[1]: *** [CMakeFiles/libi2pd.dir/all] Error 2
make: *** [all] Error 2

I used this line to configure: cmake -DCMAKE_C_COMPILER=/opt/svacchanda/gcc11ppc/bin/gcc -DCMAKE_CXX_COMPILER=/opt/svacchanda/gcc11ppc/bin/g++ -DLLVM_DEFAULT_TARGET_TRIPLE=powerpc-apple-darwin10 -DBoost_INCLUDE_DIR=/opt/local/libexec/boost/1.76/include

barracuda156 avatar Feb 10 '22 12:02 barracuda156

Do you know any defines, which compilator adds when building with OSX SDK? I've tested build with Homebrew and never seen such error here.

r4sas avatar Feb 10 '22 20:02 r4sas

Do you know any defines, which compilator adds when building with OSX SDK? I've tested build with Homebrew and never seen such error here.

Which compiler has you used? If it is some version of gcc, I can try that.

P. S. I will update soon on what happens on 10.5.8 and 10.6 PPC. Currently running some other stuff, need to wait until it builds.

barracuda156 avatar Feb 10 '22 20:02 barracuda156

Homebrew using same gcc, but I don't know which version now. I'll try to run my VM with it (I don't have any real Mac here ;D) and try to check

r4sas avatar Feb 10 '22 20:02 r4sas

Try latest commit.

r4sas avatar Feb 10 '22 21:02 r4sas

@r4sas I tried to build on 10.5.8 now with gcc11, and it still fails on:

/Users/svacchanda/Dev/i2pd/libi2pd/util.cpp: In function ‘void i2p::util::SetThreadName(const char*)’:
/Users/svacchanda/Dev/i2pd/libi2pd/util.cpp:127:17: error: ‘pthread_setname_np’ was not declared in this scope; did you mean ‘pthread_setugid_np’?
  127 |                 pthread_setname_np((char*)name);
      |                 ^~~~~~~~~~~~~~~~~~
      |                 pthread_setugid_np
make[2]: *** [CMakeFiles/libi2pd.dir/Users/svacchanda/Dev/i2pd/libi2pd/util.cpp.o] Error 1
make[2]: *** Waiting for unfinished jobs....
make[1]: *** [CMakeFiles/libi2pd.dir/all] Error 2
make: *** [all] Error 2

gcc11:

36-47:~ svacchanda$ /opt/svacchanda/gcc11/bin/g++ -v
Using built-in specs.
COLLECT_GCC=/opt/svacchanda/gcc11/bin/g++
COLLECT_LTO_WRAPPER=/opt/svacchanda/gcc11/libexec/gcc/powerpc-apple-darwin9/11.2.1/lto-wrapper
Target: powerpc-apple-darwin9
Configured with: ../configure --prefix=/opt/svacchanda/gcc11 --build=powerpc-apple-darwin9 --with-as=/usr/bin/as --with-ld=/usr/bin/ld --enable-languages=all CC=/opt/iains/powerpc-apple-darwin9/gcc-10-3-ppc/bin/gcc CXX=/opt/iains/powerpc-apple-darwin9/gcc-10-3-ppc/bin/g++
Thread model: posix
Supported LTO compression algorithms: zlib
gcc version 11.2.1 20211013 (GCC)

I will with other compiler, but gcc11 should have been fine, it's the latest one.

barracuda156 avatar Feb 10 '22 23:02 barracuda156

@r4sas Ok, so it fails with stock macports-gcc-7 too, which is thoroughly tested and 100% works (I have just built boost176 with it).

So I cloned current i2pd repo, then:

36-47:~ svacchanda$ cd /Users/svacchanda/Dev/i2pd\ copy\ 2/build 
36-47:build svacchanda$ cmake -DCMAKE_C_COMPILER=/opt/local/bin/gcc-mp-7 -DCMAKE_CXX_COMPILER=/opt/local/bin/g++-mp-7 -DBoost_INCLUDE_DIR=/opt/local/libexec/boost/1.76/include
CMake Warning:
  No source or binary directory provided.  Both will be assumed to be the
  same as the current working directory, but note that this warning will
  become a fatal error in future CMake releases.


-- The C compiler identification is GNU 7.5.0
-- The CXX compiler identification is GNU 7.5.0
-- Checking whether C compiler has -isysroot
-- Checking whether C compiler has -isysroot - yes
-- Checking whether C compiler supports OSX deployment target flag
-- Checking whether C compiler supports OSX deployment target flag - yes
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /opt/local/bin/gcc-mp-7 - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Checking whether CXX compiler has -isysroot
-- Checking whether CXX compiler has -isysroot - yes
-- Checking whether CXX compiler supports OSX deployment target flag
-- Checking whether CXX compiler supports OSX deployment target flag - yes
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /opt/local/bin/g++-mp-7 - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Performing Test CXX17_SUPPORTED
-- Performing Test CXX17_SUPPORTED - Success
-- Performing Test CXX11_SUPPORTED
-- Performing Test CXX11_SUPPORTED - Success
-- Looking for pthread.h
-- Looking for pthread.h - found
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Success
-- Found Threads: TRUE  
-- Found Boost: /opt/local/libexec/boost/1.76/include (found version "1.76.0") found components: system filesystem program_options date_time 
-- Found OpenSSL: /opt/local/libexec/openssl3/lib/libcrypto.dylib (found version "3.0.1")  
-- Found ZLIB: /opt/local/lib/libz.dylib (found version "1.2.11") 
-- Performing Test HAVE_CXX_ATOMICS64_WITHOUT_LIB
-- Performing Test HAVE_CXX_ATOMICS64_WITHOUT_LIB - Failed
-- Looking for __atomic_load_8 in atomic
-- Looking for __atomic_load_8 in atomic - found
-- Performing Test HAVE_CXX_ATOMICS64_WITH_LIB
-- Performing Test HAVE_CXX_ATOMICS64_WITH_LIB - Success
-- Performing Test LLVM_HAS_ATOMICS
-- Performing Test LLVM_HAS_ATOMICS - Success
-- ---------------------------------------
-- Build type         : 
-- Compiler vendor    : GNU
-- Compiler version   : 7.5.0
-- Compiler path      : /opt/local/bin/g++-mp-7
-- Architecture       : unknown
-- Install prefix:    : /usr/local
-- Options:
--   AESNI            : ON
--   HARDENING        : OFF
--   LIBRARY          : ON
--   BINARY           : ON
--   STATIC BUILD     : OFF
--   UPnP             : OFF
--   PCH              : OFF
--   MESHNET          : OFF
--   ADDRSANITIZER    : OFF
--   THREADSANITIZER  : OFF
-- ---------------------------------------
-- Configuring done
-- Generating done
-- Build files have been written to: /Users/svacchanda/Dev/i2pd copy 2/build
36-47:build svacchanda$ make -j 4 > b.txt 2>e.txt

Same failure:

/Users/svacchanda/Dev/i2pd copy 2/libi2pd/util.cpp: In function 'void i2p::util::SetThreadName(const char*)':
/Users/svacchanda/Dev/i2pd copy 2/libi2pd/util.cpp:127:3: error: 'pthread_setname_np' was not declared in this scope
   pthread_setname_np((char*)name);
   ^~~~~~~~~~~~~~~~~~
/Users/svacchanda/Dev/i2pd copy 2/libi2pd/util.cpp:127:3: note: suggested alternative: 'pthread_setugid_np'
   pthread_setname_np((char*)name);
   ^~~~~~~~~~~~~~~~~~
   pthread_setugid_np
make[2]: *** [CMakeFiles/libi2pd.dir/Users/svacchanda/Dev/i2pd_copy_2/libi2pd/util.cpp.o] Error 1
make[2]: *** Waiting for unfinished jobs....
make[1]: *** [CMakeFiles/libi2pd.dir/all] Error 2
make: *** [all] Error 2

barracuda156 avatar Feb 11 '22 00:02 barracuda156

Here is the complete log (10.5.8, Macports gcc7):

e.txt b.txt

barracuda156 avatar Feb 11 '22 00:02 barracuda156

That's why I'm asking you about determining in code that we use MacPorts GCC with custom pthreads which not supports pthread_setname_np. At least on MacOSX10.6.sdk it must work now.

Maybe check header file pthread.h?

r4sas avatar Feb 11 '22 01:02 r4sas

@barracuda156 can you test by changing check here: https://github.com/PurpleI2P/i2pd/blob/90130b5492e0505fd88113653f4a0668e8ab2a18/libi2pd/util.cpp#L126 to #if defined(__APPLE__) && defined(CONFIG_PTHREAD_SETNAME_NP_W_TID) ?

r4sas avatar Feb 11 '22 01:02 r4sas

That's why I'm asking you about determining in code that we use MacPorts GCC with custom pthreads which not supports pthread_setname_np. At least on MacOSX10.6.sdk it must work now. Maybe check header file pthread.h?

Please excuse me, I didn’t know how to check that specifically. But I tried with non-Macports compilers initially (gcc11 does not build for ppc in Macports) and only then with Macports version of gcc7. It appears that Mac OS has some specifics with implementation of pthreads: https://help.autodesk.com/view/MAYAUL/2016/ENU/?guid=__files_GUID_EE052898_C59C_438A_9A77_798F5BEB7A77_htm

barracuda156 avatar Feb 11 '22 02:02 barracuda156

@r4sas I have tried building with gcc10 after making suggested change:

Last login: Fri Feb 11 12:01:59 on ttys000
36-47:~ svacchanda$ export CC=/opt/iains/powerpc-apple-darwin9/gcc-10-3-ppc/bin/gcc
36-47:~ svacchanda$ export CXX=/opt/iains/powerpc-apple-darwin9/gcc-10-3-ppc/bin/g++
36-47:~ svacchanda$ export CFLAGS="-arch ppc -m32"
36-47:~ svacchanda$ export CXXFLAGS="-arch ppc -m32"
36-47:~ svacchanda$ cd /Users/svacchanda/Dev/i2pd\ copy\ 2/build 
36-47:build svacchanda$ cmake -DCMAKE_C_COMPILER=/opt/iains/powerpc-apple-darwin9/gcc-10-3-ppc/bin/gcc -DCMAKE_CXX_COMPILER=/opt/iains/powerpc-apple-darwin9/gcc-10-3-ppc/bin/g++ -DCMAKE_SYSTEM_PROCESSOR="ppc" -DBoost_INCLUDE_DIR=/opt/local/libexec/boost/1.76/include
CMake Warning:
  No source or binary directory provided.  Both will be assumed to be the
  same as the current working directory, but note that this warning will
  become a fatal error in future CMake releases.


-- The C compiler identification is GNU 10.3.0
-- The CXX compiler identification is GNU 10.3.0
-- Checking whether C compiler has -isysroot
-- Checking whether C compiler has -isysroot - yes
-- Checking whether C compiler supports OSX deployment target flag
-- Checking whether C compiler supports OSX deployment target flag - yes
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /opt/iains/powerpc-apple-darwin9/gcc-10-3-ppc/bin/gcc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Checking whether CXX compiler has -isysroot
-- Checking whether CXX compiler has -isysroot - yes
-- Checking whether CXX compiler supports OSX deployment target flag
-- Checking whether CXX compiler supports OSX deployment target flag - yes
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /opt/iains/powerpc-apple-darwin9/gcc-10-3-ppc/bin/g++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Performing Test CXX17_SUPPORTED
-- Performing Test CXX17_SUPPORTED - Success
-- Performing Test CXX11_SUPPORTED
-- Performing Test CXX11_SUPPORTED - Success
-- Looking for pthread.h
-- Looking for pthread.h - found
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Success
-- Found Threads: TRUE  
-- Found Boost: /opt/local/libexec/boost/1.76/include (found version "1.76.0") found components: system filesystem program_options date_time 
-- Found OpenSSL: /opt/local/libexec/openssl3/lib/libcrypto.dylib (found version "3.0.1")  
-- Found ZLIB: /opt/local/lib/libz.dylib (found version "1.2.11") 
-- Performing Test HAVE_CXX_ATOMICS64_WITHOUT_LIB
-- Performing Test HAVE_CXX_ATOMICS64_WITHOUT_LIB - Failed
-- Looking for __atomic_load_8 in atomic
-- Looking for __atomic_load_8 in atomic - found
-- Performing Test HAVE_CXX_ATOMICS64_WITH_LIB
-- Performing Test HAVE_CXX_ATOMICS64_WITH_LIB - Success
-- Performing Test LLVM_HAS_ATOMICS
-- Performing Test LLVM_HAS_ATOMICS - Success
-- ---------------------------------------
-- Build type         : 
-- Compiler vendor    : GNU
-- Compiler version   : 10.3.0
-- Compiler path      : /opt/iains/powerpc-apple-darwin9/gcc-10-3-ppc/bin/g++
-- Architecture       : unknown
-- Install prefix:    : /usr/local
-- Options:
--   AESNI            : ON
--   HARDENING        : OFF
--   LIBRARY          : ON
--   BINARY           : ON
--   STATIC BUILD     : OFF
--   UPnP             : OFF
--   PCH              : OFF
--   MESHNET          : OFF
--   ADDRSANITIZER    : OFF
--   THREADSANITIZER  : OFF
-- ---------------------------------------
-- Configuring done
-- Generating done
-- Build files have been written to: /Users/svacchanda/Dev/i2pd copy 2/build
36-47:build svacchanda$ make -j 4 >b.txt 2>e.txt

Unfortunately, no change:

/Users/svacchanda/Dev/i2pd copy 2/libi2pd/util.cpp: In function ‘void i2p::util::SetThreadName(const char*)’:
/Users/svacchanda/Dev/i2pd copy 2/libi2pd/util.cpp:133:3: error: ‘pthread_setname_np’ was not declared in this scope; did you mean ‘pthread_setugid_np’?
  133 |   pthread_setname_np(pthread_self(), name);
      |   ^~~~~~~~~~~~~~~~~~
      |   pthread_setugid_np
make[2]: *** [CMakeFiles/libi2pd.dir/Users/svacchanda/Dev/i2pd_copy_2/libi2pd/util.cpp.o] Error 1
make[2]: *** Waiting for unfinished jobs....
make[1]: *** [CMakeFiles/libi2pd.dir/all] Error 2
make: *** [all] Error 2

barracuda156 avatar Feb 11 '22 04:02 barracuda156

Can you find pthread.h header and send it here?

r4sas avatar Feb 11 '22 04:02 r4sas

Currently trying to test with cmake -DCMAKE_C_COMPILER=/opt/local/bin/gcc-mp-11 -DCMAKE_CXX_COMPILER=/opt/local/bin/g++-mp-11 -DBOOST_ROOT=/opt/local/libexec/boost/1.76 -DBoost_NO_SYSTEM_PATHS=TRUE -DZLIB_ROOT=/opt/local -Wno-dev .

add: failing to link binary... idk why, but boost can't find some symbols.

add2: that's why I hate cmake: /opt/local/bin/g++-mp-11 -Wall -Wextra -Winvalid-pch -Wno-unused-parameter -std=c++17 -pipe -fPIC -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX12.1.sdk -mmacosx-version-min=11.4 -Wl,-search_paths_first -Wl,-headerpad_max_install_names CMakeFiles/i2pd.dir/Users/r4sas/dev/i2pd/daemon/Daemon.cpp.o CMakeFiles/i2pd.dir/Users/r4sas/dev/i2pd/daemon/HTTPServer.cpp.o CMakeFiles/i2pd.dir/Users/r4sas/dev/i2pd/daemon/I2PControl.cpp.o CMakeFiles/i2pd.dir/Users/r4sas/dev/i2pd/daemon/i2pd.cpp.o CMakeFiles/i2pd.dir/Users/r4sas/dev/i2pd/daemon/UPnP.cpp.o CMakeFiles/i2pd.dir/Users/r4sas/dev/i2pd/daemon/UnixDaemon.cpp.o -o i2pd -L/opt/local/lib -Wl,-rpath,/opt/local/lib libi2pd.a libi2pdclient.a libi2pdlang.a /opt/local/libexec/boost/1.76/lib/libboost_system-mt.dylib /opt/local/libexec/boost/1.76/lib/libboost_filesystem-mt.dylib /opt/local/libexec/boost/1.76/lib/libboost_program_options-mt.dylib /opt/local/libexec/boost/1.76/lib/libboost_date_time-mt.dylib /opt/local/libexec/openssl11/lib/libssl.dylib /opt/local/libexec/openssl11/lib/libcrypto.dylib /opt/local/lib/libz.dylib libi2pd.a /opt/local/libexec/boost/1.76/lib/libboost_system-mt.dylib /opt/local/libexec/boost/1.76/lib/libboost_filesystem-mt.dylib /opt/local/libexec/boost/1.76/lib/libboost_program_options-mt.dylib /opt/local/libexec/boost/1.76/lib/libboost_date_time-mt.dylib /opt/local/lib/libz.dylib It is linking libi2pd.a twice.

add3: I'm able to build binary only with clang.

r4sas avatar Feb 11 '22 04:02 r4sas

@r4sas Cmake is a disaster, I agree.

Do you have an idea how we can fix it to build with some version of gcc? Clang is broken for ppc.

P. S. I just got Boost 1.78 built. Though it probably won't solve the problem.

36-47% port -v installed boost178
The following ports are currently installed:
  boost178 @1.78.0_1+no_single+no_static+python310 (active) requested_variants='' platform='darwin 10' archs='ppc' date='2022-02-11T16:59:21+0800'

P. P. S. If it does not build due to compiler bug, I can open Bugzilla ticket for gcc.

barracuda156 avatar Feb 11 '22 11:02 barracuda156

Can you find pthread.h header and send it here?

Yes, sure. Archive.zip

barracuda156 avatar Feb 11 '22 11:02 barracuda156

Hm. 10.6 header has option, using same type as we used (const char*), but why compiler tells that "char*" is needed - idk. Maybe wrong header? Difference with 10.5.8 only in 2 lines, where pthread_setname_np is not exists.

Let's do it other way, just remove calling for __powerpc__. I'll push commit.

r4sas avatar Feb 11 '22 19:02 r4sas

@r4sas Thank you! Now files are built with a single warning:

ranlib: file: libi2pd.a(I2PEndian.cpp.o) has no symbols
/usr/bin/ranlib: file: libi2pd.a(I2PEndian.cpp.o) has no symbols

However linking stage fails:

[100%] Linking CXX executable i2pd
ld warning: duplicate dylib /opt/local/libexec/boost/1.76/lib/libboost_system-mt.dylib
ld warning: duplicate dylib /opt/local/libexec/boost/1.76/lib/libboost_filesystem-mt.dylib
ld warning: duplicate dylib /opt/local/libexec/boost/1.76/lib/libboost_program_options-mt.dylib
ld warning: duplicate dylib /opt/local/libexec/boost/1.76/lib/libboost_date_time-mt.dylib
Undefined symbols:
  "__ZN5boost15program_options11to_internalERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE", referenced from:
      __ZN5boost15program_options11to_internalINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEEESt6vectorIS7_SaIS7_EERKS8_IT_SaISB_EE in libi2pd.a(Config.cpp.o)
  "__ZN5boost15program_options22error_with_option_nameC2ERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEES9_S9_i", referenced from:
      __ZN5boost15program_options16validation_errorC1ENS1_6kind_tERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESA_i in libi2pd.a(Config.cpp.o)
  "__ZN5boost15program_options6detail7cmdlineC2ERKSt6vectorINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESaIS9_EE", referenced from:
      __ZN5boost15program_options25basic_command_line_parserIcEC1EiPKPKc in libi2pd.a(Config.cpp.o)
  "__ZN5boost15program_options19options_descriptionC1ERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEjj", referenced from:
      __ZN3i2p6config4InitEv in libi2pd.a(Config.cpp.o)
      __ZN3i2p6config4InitEv in libi2pd.a(Config.cpp.o)
      __ZN3i2p6config4InitEv in libi2pd.a(Config.cpp.o)
      __ZN3i2p6config4InitEv in libi2pd.a(Config.cpp.o)
      __ZN3i2p6config4InitEv in libi2pd.a(Config.cpp.o)
      __ZN3i2p6config4InitEv in libi2pd.a(Config.cpp.o)
      __ZN3i2p6config4InitEv in libi2pd.a(Config.cpp.o)
      __ZN3i2p6config4InitEv in libi2pd.a(Config.cpp.o)
      __ZN3i2p6config4InitEv in libi2pd.a(Config.cpp.o)
      __ZN3i2p6config4InitEv in libi2pd.a(Config.cpp.o)
      __ZN3i2p6config4InitEv in libi2pd.a(Config.cpp.o)
      __ZN3i2p6config4InitEv in libi2pd.a(Config.cpp.o)
      __ZN3i2p6config4InitEv in libi2pd.a(Config.cpp.o)
      __ZN3i2p6config4InitEv in libi2pd.a(Config.cpp.o)
      __ZN3i2p6config4InitEv in libi2pd.a(Config.cpp.o)
      __ZN3i2p6config4InitEv in libi2pd.a(Config.cpp.o)
      __ZN3i2p6config4InitEv in libi2pd.a(Config.cpp.o)
      __ZN3i2p6config4InitEv in libi2pd.a(Config.cpp.o)
      __ZN3i2p6config4InitEv in libi2pd.a(Config.cpp.o)
      __ZN3i2p6config4InitEv in libi2pd.a(Config.cpp.o)
      __ZN3i2p6config4InitEv in libi2pd.a(Config.cpp.o)
  "__ZN5boost15program_options8validateERNS_3anyERKSt6vectorINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESaIS9_EEPS9_i", referenced from:
      __ZNK5boost15program_options11typed_valueINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEcE6xparseERNS_3anyERKSt6vectorIS7_SaIS7_EE in libi2pd.a(Config.cpp.o)
  "__ZNK5boost15program_options22abstract_variables_mapixERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE", referenced from:
      __ZNK5boost15program_options13variables_mapixERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE in Daemon.cpp.o
      __ZNK5boost15program_options13variables_mapixERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE in HTTPServer.cpp.o
      __ZNK5boost15program_options13variables_mapixERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE in I2PControl.cpp.o
      __ZNK5boost15program_options13variables_mapixERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE in UnixDaemon.cpp.o
      __ZNK5boost15program_options13variables_mapixERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE in libi2pd.a(Config.cpp.o)
      __ZNK5boost15program_options13variables_mapixERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE in libi2pd.a(Transports.cpp.o)
      __ZNK5boost15program_options13variables_mapixERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE in libi2pd.a(NetDb.cpp.o)
      __ZNK5boost15program_options13variables_mapixERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE in libi2pd.a(RouterContext.cpp.o)
      __ZNK5boost15program_options13variables_mapixERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE in libi2pd.a(Destination.cpp.o)
      __ZNK5boost15program_options13variables_mapixERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE in libi2pd.a(Tunnel.cpp.o)
      __ZNK5boost15program_options13variables_mapixERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE in libi2pdclient.a(ClientContext.cpp.o)
      __ZNK5boost15program_options13variables_mapixERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE in libi2pd.a(Timestamp.cpp.o)
      __ZNK5boost15program_options13variables_mapixERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE in libi2pdclient.a(AddressBook.cpp.o)
      __ZNK5boost15program_options13variables_mapixERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE in libi2pd.a(SSU.cpp.o)
      __ZNK5boost15program_options13variables_mapixERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE in libi2pd.a(Reseed.cpp.o)
  "__ZN5boost15program_options8validateERNS_3anyERKSt6vectorINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESaIS9_EEPbi", referenced from:
      __ZNK5boost15program_options11typed_valueIbcE6xparseERNS_3anyERKSt6vectorINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESaISB_EE in libi2pd.a(Config.cpp.o)
  "__ZNK5boost15program_options22error_with_option_name23substitute_placeholdersERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE", referenced from:
      __ZTVN5boost15program_options20invalid_option_valueE in libi2pd.a(Config.cpp.o)
      __ZTVN5boost15program_options16validation_errorE in libi2pd.a(Config.cpp.o)
      __ZTVN5boost10wrapexceptINS_15program_options16validation_errorEEE in libi2pd.a(Config.cpp.o)
      __ZTVN5boost10wrapexceptINS_15program_options20invalid_option_valueEEE in libi2pd.a(Config.cpp.o)
  "__ZN5boost15program_options20invalid_option_valueC1ERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE", referenced from:
      __ZN5boost15program_options8validateIjcEEvRNS_3anyERKSt6vectorINSt7__cxx1112basic_stringIT0_St11char_traitsIS7_ESaIS7_EEESaISB_EEPT_l in libi2pd.a(Config.cpp.o)
      __ZN5boost15program_options8validateIicEEvRNS_3anyERKSt6vectorINSt7__cxx1112basic_stringIT0_St11char_traitsIS7_ESaIS7_EEESaISB_EEPT_l in libi2pd.a(Config.cpp.o)
      __ZN5boost15program_options8validateItcEEvRNS_3anyERKSt6vectorINSt7__cxx1112basic_stringIT0_St11char_traitsIS7_ESaIS7_EEESaISB_EEPT_l in libi2pd.a(Config.cpp.o)
  "__ZN5boost15program_options16validation_error12get_templateB5cxx11ENS1_6kind_tE", referenced from:
      __ZN5boost15program_options16validation_errorC1ENS1_6kind_tERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESA_i in libi2pd.a(Config.cpp.o)
  "__ZN5boost15program_options6detail7cmdline21set_additional_parserENS_9function1ISt4pairINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESA_ERKSA_EE", referenced from:
      __ZN5boost15program_options25basic_command_line_parserIcE12extra_parserENS_9function1ISt4pairINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESA_ERKSA_EE in libi2pd.a(Config.cpp.o)
  "__ZN5boost15program_options3argB5cxx11E", referenced from:
      __ZN5boost15program_options3argB5cxx11E$non_lazy_ptr in libi2pd.a(Config.cpp.o)
  "__ZNK5boost15program_options29value_semantic_codecvt_helperIcE5parseERNS_3anyERKSt6vectorINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESaISB_EEb", referenced from:
      __ZTVN5boost15program_options11typed_valueIjcEE in libi2pd.a(Config.cpp.o)
      __ZTVN5boost15program_options11typed_valueIicEE in libi2pd.a(Config.cpp.o)
      __ZTVN5boost15program_options11typed_valueItcEE in libi2pd.a(Config.cpp.o)
      __ZTVN5boost15program_options11typed_valueIbcEE in libi2pd.a(Config.cpp.o)
      __ZTVN5boost15program_options11typed_valueINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEcEE in libi2pd.a(Config.cpp.o)
ld: symbol(s) not found
collect2: error: ld returned 1 exit status
make[2]: *** [i2pd] Error 1
make[1]: *** [CMakeFiles/i2pd.dir/all] Error 2
make: *** [all] Error 2

barracuda156 avatar Feb 12 '22 18:02 barracuda156

@r4sas Above was on 10.6 PPC (10A190).

On a stock 10.5.8 however the build fails as before with:

/Users/svacchanda/i2pd/libi2pd/util.cpp: In function ‘void i2p::util::SetThreadName(const char*)’:
/Users/svacchanda/i2pd/libi2pd/util.cpp:127:17: error: ‘pthread_setname_np’ was not declared in this scope; did you mean ‘pthread_setugid_np’?
  127 |                 pthread_setname_np((char*)name);
      |                 ^~~~~~~~~~~~~~~~~~
      |                 pthread_setugid_np
make[2]: *** [CMakeFiles/libi2pd.dir/Users/svacchanda/i2pd/libi2pd/util.cpp.o] Error 1
make[2]: *** Waiting for unfinished jobs....
make[1]: *** [CMakeFiles/libi2pd.dir/all] Error 2
make: *** [all] Error 2

In either case gcc11 was used and Boost 1.76.

barracuda156 avatar Feb 12 '22 18:02 barracuda156

I found how to get all predefined macros: https://stackoverflow.com/a/10905013. Let's see what returns 10.5.8,

r4sas avatar Feb 13 '22 02:02 r4sas

@r4sas Thank you! Now files are built with a single warning:

That's not problem, because code generated only when required

However linking stage fails:

Same for me with gcc. I really don't know why, but looks like libraries built by clang in latest versions, because only with it I built i2pd succesfully.

r4sas avatar Feb 13 '22 02:02 r4sas

@r4sas Interesting. Firstly, this seems to be a rather unique case when building something has more success on 10.6 PPC (which is a developer build lacking many features of 10.6 release and therefore it may be tricky to build stuff for it) than on a vanilla 10.5.8 which has been tested and polished. Unless I am doing something wrong.

Secondly, unclear why the latest gcc11 fails here. Do you think it is a compiler fault or what? The difficulty is that I cannot really file any bugzilla reports for 10.6 PPC (well, technically I may, but no one will test it). If we find a way to reach same linking stage errors on 10.5.8, I will try asking gcc developers what's going on.

barracuda156 avatar Feb 13 '22 03:02 barracuda156

No, there is no linking problem, there is library itself diffirence, because you trying to link clang built libraries with applicaton built by gcc and using gcc linker. So solution can be in rebuilding libraries from scratch with gcc and using them for linking with app.

r4sas avatar Feb 13 '22 17:02 r4sas

No, there is no linking problem, there is library itself diffirence, because you trying to link clang built libraries with applicaton built by gcc and using gcc linker.

So solution can be in rebuilding libraries from scratch with gcc and using them for linking with app.

I have no libraries built with Clang. Everything that is not a part of OS itself is built with gcc.

barracuda156 avatar Feb 14 '22 09:02 barracuda156

I have no libraries built with Clang. Everything that is not a part of OS itself is built with gcc.

Are they built with gcc?

ld warning: duplicate dylib /opt/local/libexec/boost/1.76/lib/libboost_system-mt.dylib

That prefix used by macports as I know.

r4sas avatar Feb 14 '22 12:02 r4sas

@herbygillot, can you say to us, is libraries provided by macports are built with clang?

r4sas avatar Feb 14 '22 12:02 r4sas

@herbygillot, can you say to us, is libraries provided by macports are built with clang?

clang is broken for PowerPC. Everything that is currently built with Macports on PowerPC systems is built with gcc. At the moment macports-gcc-7 is the default version on 10.5.8 (and on 10.6 PPC, though the latter one is unofficial).

barracuda156 avatar Feb 14 '22 13:02 barracuda156

@r4sas So yes, boost is built with gcc7 for PowerPC.

It does't show in port -v installed:

36-47:~ svacchanda$ port -v installed boost176
The following ports are currently installed:
  boost176 @1.76.0_3+no_single+no_static+python310 (active) requested_variants='-universal' platform='darwin 9' archs='ppc' date='2022-02-11T07:22:32+0800'

But trust me, it's the case. Anyone on Macports can confirm that.

I don't even have clang installed. @kencu has been able to get clang-5.0 installed on PowerPC, but it produced broken code. https://trac.macports.org/ticket/53184

36-47:~ svacchanda$ port -v installed | grep clang
  clang_select @2.2_0 (active) requested_variants='' platform='darwin 9' archs='ppc ppc64' date='2022-01-18T18:52:49+0800'
36-47:~ svacchanda$ port -v installed | grep gcc
  floppy @7.0_0+gcc7 (active) requested_variants='' platform='darwin 9' archs='ppc' date='2022-01-31T19:22:03+0800'
  ftidy @7.2_2+gcc7 (active) requested_variants='' platform='darwin 9' archs='ppc' date='2022-01-31T18:26:52+0800'
  gcc6 @6.5.0_6+universal requested_variants='+universal' platform='darwin 9' archs='ppc ppc64' date='2021-12-25T01:25:21+0800'
  gcc6 @6.5.0_7+universal (active) requested_variants='+universal' platform='darwin 9' archs='ppc ppc64' date='2022-01-03T00:20:22+0800'
  gcc7 @7.5.0_2+universal requested_variants='+universal' platform='darwin 9' archs='ppc ppc64' date='2021-12-22T07:30:13+0800'
  gcc7 @7.5.0_3+universal (active) requested_variants='+universal' platform='darwin 9' archs='ppc ppc64' date='2022-01-04T17:43:56+0800'
  gcc10 @10.3.0_1+universal (active) requested_variants='+universal' platform='darwin 9' archs='ppc ppc64' date='2022-02-03T01:56:41+0800'
  gcc_select @0.1_9 (active) requested_variants='' platform='darwin 9' archs='noarch' date='2021-12-21T10:29:35+0800'
  libgcc @5.0_0+universal (active) requested_variants='+universal' platform='darwin 9' archs='ppc ppc64' date='2022-02-03T04:24:12+0800'
  libgcc6 @6.5.0_4+universal (active) requested_variants='+universal' platform='darwin 9' archs='ppc ppc64' date='2021-12-22T21:21:01+0800'
  libgcc7 @7.5.0_1+universal (active) requested_variants='+universal' platform='darwin 9' archs='ppc ppc64' date='2021-12-22T03:49:53+0800'
  libgcc10 @10.3.0_2+universal (active) requested_variants='+universal' platform='darwin 9' archs='ppc ppc64' date='2022-02-03T04:30:07+0800'
  libxc4 @4.3.4_0+gcc7 (active) requested_variants='' platform='darwin 9' archs='ppc' date='2022-01-31T18:06:30+0800'
  mpich-gcc10 @3.4.2_0 requested_variants='-universal' platform='darwin 9' archs='ppc' date='2022-02-03T03:40:23+0800'
  mpich-gcc10 @3.4.2_0+fortran (active) requested_variants='+fortran-universal' platform='darwin 9' archs='ppc' date='2022-02-03T05:44:13+0800'
  pgplot @5.2.2_13+gcc7+x11 (active) requested_variants='' platform='darwin 9' archs='ppc' date='2022-02-03T02:30:32+0800'
  slatec @4.1_2+gcc7 (active) requested_variants='' platform='darwin 9' archs='ppc' date='2022-01-31T18:35:37+0800'

barracuda156 avatar Feb 14 '22 13:02 barracuda156

Hm... In that case I can't say anything. Can you try rebuild boost locally?

r4sas avatar Feb 14 '22 17:02 r4sas

Hm... In that case I can't say anything. Can you try rebuild boost locally?

@r4sas Sure, I will do that in a couple of days. I wanna rebuild gcc incorporating this patch first: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104117

barracuda156 avatar Feb 15 '22 11:02 barracuda156

@r4sas Above was on 10.6 PPC (10A190).

On a stock 10.5.8 however the build fails as before with:

/Users/svacchanda/i2pd/libi2pd/util.cpp: In function ‘void i2p::util::SetThreadName(const char*)’:
/Users/svacchanda/i2pd/libi2pd/util.cpp:127:17: error: ‘pthread_setname_np’ was not declared in this scope; did you mean ‘pthread_setugid_np’?
  127 |                 pthread_setname_np((char*)name);
      |                 ^~~~~~~~~~~~~~~~~~
      |                 pthread_setugid_np
make[2]: *** [CMakeFiles/libi2pd.dir/Users/svacchanda/i2pd/libi2pd/util.cpp.o] Error 1
make[2]: *** Waiting for unfinished jobs....
make[1]: *** [CMakeFiles/libi2pd.dir/all] Error 2
make: *** [all] Error 2

In either case gcc11 was used and Boost 1.76.

@r4sas Above was on 10.6 PPC (10A190).

On a stock 10.5.8 however the build fails as before with:

/Users/svacchanda/i2pd/libi2pd/util.cpp: In function ‘void i2p::util::SetThreadName(const char*)’:
/Users/svacchanda/i2pd/libi2pd/util.cpp:127:17: error: ‘pthread_setname_np’ was not declared in this scope; did you mean ‘pthread_setugid_np’?
  127 |                 pthread_setname_np((char*)name);
      |                 ^~~~~~~~~~~~~~~~~~
      |                 pthread_setugid_np

pthread_setname_np() is not available until 10.6.x where x might == 8 (I have only that to check). So you would need to find an alternative or omit the functionality for earlier OS versions. (nothing to do with the compiler here - although perhaps the configuration).

...

iains avatar Mar 01 '22 23:03 iains