Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nsoblath/issue 212 #217

Merged
merged 20 commits into from
Apr 13, 2022
Merged

Nsoblath/issue 212 #217

merged 20 commits into from
Apr 13, 2022

Conversation

nsoblath
Copy link
Collaborator

@nsoblath nsoblath commented Mar 5, 2022

Statically link Python in Mac and Linux builds.

Closes #212

@nsoblath nsoblath self-assigned this Mar 5, 2022
@nsoblath
Copy link
Collaborator Author

nsoblath commented Mar 21, 2022

Update: Added explicit linking to thread library, libdl, and libutil (the latter two for non-Windows). Test builds work.

Unfortunately the mac and linux builds both are still dynamically linked to Python 😒

The verbose printout from the linking command doesn't seem to show us linking against libpython3.9.so:

/usr/bin/c++ -Wall -Wpedantic -fpermissive -fPIC -O2 -g -DNDEBUG -Wl,--no-as-needed CMakeFiles/apbs.dir/main.c.o -o apbs -L/home/runner/work/apbs/apbs/build/_deps/tabi-build/lib ../_deps/fetk-build/maloc/src/libmaloc.a ../_deps/fetk-build/punc/src/libpunc.a ../_deps/fetk-build/mc/src/libmc.a ../_deps/fetk-build/gamer/src/libgamer.a ../_deps/superlu-build/SRC/libsuperlu.a ../_deps/fetk-build/punc/src/vf2c/libvf2c.a -lutil -ldl -lm -lstdc++ -lpthread /usr/lib/x86_64-linux-gnu/libumfpack.a /usr/lib/x86_64-linux-gnu/libspqr.a /usr/lib/x86_64-linux-gnu/libcholmod.a /usr/lib/x86_64-linux-gnu/libccolamd.a /usr/lib/x86_64-linux-gnu/libcamd.a /usr/lib/x86_64-linux-gnu/libcolamd.a /usr/lib/x86_64-linux-gnu/libamd.a /usr/lib/x86_64-linux-gnu/libopenblas.a /usr/lib/x86_64-linux-gnu/liblapack.a /usr/lib/x86_64-linux-gnu/libopenblas.a /usr/lib/x86_64-linux-gnu/libopenblas.a /usr/lib/x86_64-linux-gnu/libsuitesparseconfig.a /usr/lib/x86_64-linux-gnu/librt.a /usr/local/lib/libmetis.a /opt/hostedtoolcache/Python/3.9.10/x64/lib/python3.9/config-3.9-x86_64-linux-gnu/libpython3.9.a ../libTABIPBlib.a ../_deps/geoflow-build/lib/libGeometricFlowLib.a ../contrib/iapbs/src/libiapbs.a generic/libapbs_generic.a pmgc/libapbs_pmgc.a mg/libapbs_mg.a fem/libapbs_fem.a geoflow/libapbs_geoflow_apbs.a libapbs_routines.a mg/libapbs_mg.a pmgc/libapbs_pmgc.a fem/libapbs_fem.a generic/libapbs_generic.a geoflow/libapbs_geoflow_apbs.a ../_deps/fetk-build/mc/src/libmc.a ../_deps/fetk-build/punc/src/libpunc.a ../_deps/fetk-build/gamer/src/libgamer.a ../_deps/fetk-build/maloc/src/libmaloc.a ../_deps/superlu-build/SRC/libsuperlu.a ../_deps/fetk-build/punc/src/vf2c/libvf2c.a -lutil -ldl -lm -lstdc++ -lpthread /usr/lib/x86_64-linux-gnu/libumfpack.a /usr/lib/x86_64-linux-gnu/libspqr.a /usr/lib/x86_64-linux-gnu/libcholmod.a /usr/lib/x86_64-linux-gnu/libccolamd.a /usr/lib/x86_64-linux-gnu/libcamd.a /usr/lib/x86_64-linux-gnu/libcolamd.a /usr/lib/x86_64-linux-gnu/libamd.a /usr/lib/x86_64-linux-gnu/libopenblas.a /usr/lib/x86_64-linux-gnu/liblapack.a /usr/lib/x86_64-linux-gnu/libopenblas.a /usr/lib/x86_64-linux-gnu/liblapack.a /usr/lib/x86_64-linux-gnu/libsuitesparseconfig.a /usr/lib/x86_64-linux-gnu/librt.a /usr/local/lib/libmetis.a /opt/hostedtoolcache/Python/3.9.10/x64/lib/python3.9/config-3.9-x86_64-linux-gnu/libpython3.9.a ../libTABIPBlib.a ../_deps/geoflow-build/lib/libGeometricFlowLib.a ../contrib/iapbs/src/libiapbs.a

@nsoblath
Copy link
Collaborator Author

nsoblath commented Apr 1, 2022

Update [actually from 3/21/22]: On Linux the static linking to Python is actually working. On Mac, it appears to be statically linking libpython3.9.a, but the Framework still shows up when I call otool -L on the apbs executable. The test run works without separately installing Python because the Mac GitHub-hosted runner already has Python 3.9 installed.

@nsoblath nsoblath force-pushed the nsoblath/issue_212 branch from e4d9f58 to 4deb770 Compare April 12, 2022 20:44
@nsoblath
Copy link
Collaborator Author

Update: Mac build solved by linking to the Intl and Iconv packages (for non-Windows) and the CoreUtilities framework for macOS. At this point, Python has now been statically linked in (see checks below).

Currently the test jobs are not even starting because of some problem with the build.yaml job specification. I'm going to try reverting some of the other changes that were made to that file to test the python linking, and see if that fixes whatever's causing the test job to fail.

Here's the libraries dynamically linked to the apbs binary in the Mac build:

➜  bin otool -L apbs
apbs:
	/usr/lib/libutil.dylib (compatibility version 1.0.0, current version 1.0.0)
	/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1311.0.0)
	/usr/lib/libc++.1.dylib (compatibility version 1.0.0, current version 1200.3.0)
	/usr/lib/libiconv.2.dylib (compatibility version 7.0.0, current version 7.0.0)
	/System/Library/Frameworks/Accelerate.framework/Versions/A/Accelerate (compatibility version 1.0.0, current version 4.0.0)
	/System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation (compatibility version 150.0.0, current version 1856.105.0)

And here are the libraries dynamically linked to the apbs binary in the linux build:

root@109cdbd4dfe5:/apbs/bin# ldd apbs
	linux-vdso.so.1 (0x00007ffecf1f5000)
	libutil.so.1 => /lib/x86_64-linux-gnu/libutil.so.1 (0x00007fba841cf000)
	libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007fba841c9000)
	libstdc++.so.6 => /lib/x86_64-linux-gnu/libstdc++.so.6 (0x00007fba83fe7000)
	libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007fba83fc4000)
	libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007fba83e75000)
	libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007fba83e5a000)
	libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007fba83c66000)
	/lib64/ld-linux-x86-64.so.2 (0x00007fba85e93000)

@nsoblath nsoblath marked this pull request as ready for review April 13, 2022 22:48
@nsoblath nsoblath requested a review from intendo April 13, 2022 22:49
@intendo intendo merged commit 551c816 into main Apr 13, 2022
@intendo intendo deleted the nsoblath/issue_212 branch April 13, 2022 22:54
intendo pushed a commit that referenced this pull request Apr 29, 2022
* Fixed syntax errors in checking for max python version (#208)

* Fixed syntax errors in checking for max python version

* Switch OS specification to absolute versions and reduce places where those are specified

* Update Windows config to Visual Studio 17 2022

* skip ci -- Updated releases.rst with update info

* [skip ci] Added release note

Co-authored-by: Noah Oblath <noah.oblath@pnnl.gov>

* Change OS specification in build workflow (#210)

* Switch OS specification to absolute versions and reduce places where those are specified

* Update Windows config to Visual Studio 17 2022

* skip ci -- Updated releases.rst with update info

Co-authored-by: Noah Oblath <noah.oblath@pnnl.gov>
Co-authored-by: Darren Curtis <Darren.Curtis@pnnl.gov>

* Nsoblath/issue 212 (#217)

* Turn off debugging steps

* Only install python in Windows for "Test Usage" job, as we'll be statically linking Python in Mac and Linux.

* Search for static python libs in linux and mac when doing a static build

* Turn on tmate to check library linking

* Find threads explicitly

* Tmate only on failure

* Verbose build for debugging

* Added two more missing libraries: libdl and libutil

* Enable tmate for the mac use-test job

* Test with Python 3.10

* Test with Python 3.10 revealed we needed libintl.  So that's added now.  Should be mac-specific

* Can't include_directories() on an empty variable

* Typo fix

* Find Iconv

* Add linking of APBS to CoreFoundation framework under macOS

* Remove debugging

* Removing some of the debugging tools used in testing the build.

* Switch back to the standard build with Python 3.9

* Removed last tmate debugging

* [skip ci] Document changes

Co-authored-by: Noah Oblath <noah.oblath@pnnl.gov>

* Nsoblath/issue 222 (#223)

* First committed version of Dockerfile.centos

* Add alt config workflow

* Alt config build: test docker builds

* In Dockerfile, specify APBS_STATIC_BUILD instead of BUILD_SHARED_LIBS

* Missing backslash found

* Fixing bugs in both Dockerfiles

* Dockerfile bug fixing

* Complete missing pieces of ensuring a position-independent-code build

* Minor fixes

* Switch to a shared-library build in the Ubuntu Docker build

* Rename Dockerfile --> Dockerfile.ubuntu

* Override APBS_STATIC_BUILD when needed

Co-authored-by: Noah Oblath <noah.oblath@pnnl.gov>

* Remove all mention of ENABLE_FETK (#225)

Co-authored-by: Noah Oblath <noah.oblath@pnnl.gov>

* Nsoblath/issue 226: FETK update (#227)

* Address missing linkages

* Cleanup FETK import

* Multithreaded build in docker now controlled by a build argument

* Install superlu as a dependency in the Ubuntu docker build

* Update the FETK version in use by the automatic builds (still on a development branch)

* Add in debugging tmate session for mac

* Manually build arpack to get the static lib (which seems to have disappeared?)

* Remove -j flags

* Set fortran compiler for arpack build

* Engaging brain, fixing mac-build commands

* Comment out tmate session

* Update the FETK commit to be the main branch, pre-release

* Update the changelog

* Updated default FETK build to commit v1.9.3 (57195e)

Co-authored-by: Noah Oblath <noah.oblath@pnnl.gov>

* Nsoblath/new issue 207: Addressing python version test (#229)

* Fix python test max-version test in apbs/CMakeLists.txt

* Turn on the alternate non-docker builds, with updates from the main build

* Fixing the python max version test in apbs/tests/CMakeLists.txt

* Fixing the python max version test in apbs/tools/python/CMakeLists.txt

* Test commit: remove python-max-version definition

* Simplify the Python search by looking for an exact version

* Add a default PYTHON_VERSION

* Adapt the various files involved in building APBS to the new Python version setup

* Didn't setup the python version correctly in the GHA builds

Co-authored-by: Noah Oblath <noah.oblath@pnnl.gov>

* Updated installation documentation (#231)

Co-authored-by: Noah Oblath <noah.oblath@pnnl.gov>

* Updated license, version, and release info for pending release

Co-authored-by: Noah Oblath <noah.oblath@pnnl.gov>
Co-authored-by: Darren Curtis <Darren.Curtis@pnnl.gov>
@alexreg
Copy link

alexreg commented Sep 27, 2022

Unfortunately, this still seems to be an issue in the 3.4.1 release.

Performing C SOURCE FILE Test Intl_IS_BUILT_IN failed with the following output:
Change Dir: /tmp/apbs-20220926-39068-n0ircz/build/CMakeFiles/CMakeTmp

Run Build Command(s):/opt/homebrew/bin/gmake -f Makefile cmTC_799a3/fast && /opt/homebrew/bin/gmake  -f CMakeFiles/cmTC_799a3.dir/build.make CMakeFiles/cmTC_799a3.dir/build
gmake[1]: Entering directory '/private/tmp/apbs-20220926-39068-n0ircz/build/CMakeFiles/CMakeTmp'
Building C object CMakeFiles/cmTC_799a3.dir/src.c.o
/opt/homebrew/Library/Homebrew/shims/mac/super/gcc-12 -DIntl_IS_BUILT_IN  -fopenmp -fPIC  -arch arm64 -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX12.sdk -o CMakeFiles/cmTC_799a3.dir/src.c.o -c /tmp/apbs-20220926-39068-n0ircz/build/CMakeFiles/CMakeTmp/src.c
Linking C executable cmTC_799a3
/opt/homebrew/Cellar/cmake/3.24.2/bin/cmake -E cmake_link_script CMakeFiles/cmTC_799a3.dir/link.txt --verbose=1
/opt/homebrew/Library/Homebrew/shims/mac/super/gcc-12 -fopenmp -fPIC  -arch arm64 -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX12.sdk -Wl,-search_paths_first -Wl,-headerpad_max_install_names CMakeFiles/cmTC_799a3.dir/src.c.o -o cmTC_799a3 
Undefined symbols for architecture arm64:
  "_libintl_dcgettext", referenced from:
      _main in src.c.o
  "_libintl_dgettext", referenced from:
      _main in src.c.o
  "_libintl_gettext", referenced from:
      _main in src.c.o
ld: symbol(s) not found for architecture arm64
collect2: error: ld returned 1 exit status
gmake[1]: *** [CMakeFiles/cmTC_799a3.dir/build.make:99: cmTC_799a3] Error 1
gmake[1]: Leaving directory '/private/tmp/apbs-20220926-39068-n0ircz/build/CMakeFiles/CMakeTmp'
gmake: *** [Makefile:127: cmTC_799a3/fast] Error 2


Source file was:
#include <libintl.h>
int main(void) {
  gettext("");
  dgettext("", "");
  dcgettext("", "", 0);
  return 0;
}

Performing C SOURCE FILE Test Iconv_IS_BUILT_IN failed with the following output:
Change Dir: /tmp/apbs-20220926-39068-n0ircz/build/CMakeFiles/CMakeTmp

Run Build Command(s):/opt/homebrew/bin/gmake -f Makefile cmTC_a634d/fast && /opt/homebrew/bin/gmake  -f CMakeFiles/cmTC_a634d.dir/build.make CMakeFiles/cmTC_a634d.dir/build
gmake[1]: Entering directory '/private/tmp/apbs-20220926-39068-n0ircz/build/CMakeFiles/CMakeTmp'
Building C object CMakeFiles/cmTC_a634d.dir/src.c.o
/opt/homebrew/Library/Homebrew/shims/mac/super/gcc-12 -DIconv_IS_BUILT_IN  -fopenmp -fPIC  -arch arm64 -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX12.sdk -o CMakeFiles/cmTC_a634d.dir/src.c.o -c /tmp/apbs-20220926-39068-n0ircz/build/CMakeFiles/CMakeTmp/src.c
Linking C executable cmTC_a634d
/opt/homebrew/Cellar/cmake/3.24.2/bin/cmake -E cmake_link_script CMakeFiles/cmTC_a634d.dir/link.txt --verbose=1
/opt/homebrew/Library/Homebrew/shims/mac/super/gcc-12 -fopenmp -fPIC  -arch arm64 -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX12.sdk -Wl,-search_paths_first -Wl,-headerpad_max_install_names CMakeFiles/cmTC_a634d.dir/src.c.o -o cmTC_a634d 
Undefined symbols for architecture arm64:
  "_libiconv", referenced from:
      _main in src.c.o
  "_libiconv_close", referenced from:
      _main in src.c.o
  "_libiconv_open", referenced from:
      _main in src.c.o
ld: symbol(s) not found for architecture arm64
collect2: error: ld returned 1 exit status
gmake[1]: *** [CMakeFiles/cmTC_a634d.dir/build.make:99: cmTC_a634d] Error 1
gmake[1]: Leaving directory '/private/tmp/apbs-20220926-39068-n0ircz/build/CMakeFiles/CMakeTmp'
gmake: *** [Makefile:127: cmTC_a634d/fast] Error 2


Source file was:

      #include <stddef.h>
      #include <iconv.h>
      int main() {
        char *a, *b;
        size_t i, j;
        iconv_t ic;
        ic = iconv_open("to", "from");
        iconv(ic, &a, &i, &b, &j);
        iconv_close(ic);
      }

Incidentally, I also needed to pass -DBLA_VENDOR=OpenBLAS -DCMAKE_C_FLAGS=-fopenmp to CMake to get it this far, as well as making sure OpenMP is installed (despite -DENABLE_OPENMP=OFF).

@sobolevnrm
Copy link
Member

@alexreg should we reopen this issue?

@alexreg
Copy link

alexreg commented Sep 27, 2022

@sobolevnrm If you would, please.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Error while loading shared libraries: libpython3.9.so.1.0
4 participants