Opened 4 weeks ago

Last modified 4 weeks ago

#69628 assigned defect

Gildas 202303a fails to link on 10.8: Undefined symbols for architecture x86_64: "__ZNKSs7compareEPKc" etc.

Reported by: barracuda156 Owned by: bardeau
Priority: Normal Milestone:
Component: ports Version: 2.9.1
Keywords: mountainlion Cc:
Port: gildas

Description

/usr/bin/clang++  -I/opt/local/include   -c   -Os   -I/opt/local/include -I/opt/local/Library/Frameworks/Python.framework/Versions/3.11/include/python3.11 -I/opt/local/var/macports/build/_opt_bblocal_var_buildworker_ports_build_ports_science_gildas/gildas/work/gildas-src-mar24a/integ/x86_64-macosx-gfortran/include -pipe -fPIC -Ddarwin -DDARWIN -DOPENSSL -DPNG -O -Dunderscore -DGAG_USE_GTK -DGAG_USE_OPENMP -DGAG_USE_POSIX -DGAG_USE_PYTHON -DGAG_USE_UNDERSCORE ATMError.cpp -o built/x86_64-macosx-gfortran/ATMError.o
ar cr /opt/local/var/macports/build/_opt_bblocal_var_buildworker_ports_build_ports_science_gildas/gildas/work/gildas-src-mar24a/integ/x86_64-macosx-gfortran/lib/libatm2009.a built/x86_64-macosx-gfortran/ATMOpacity.o built/x86_64-macosx-gfortran/ATMLength.o built/x86_64-macosx-gfortran/ATMInverseLength.o built/x86_64-macosx-gfortran/ATMPressure.o built/x86_64-macosx-gfortran/ATMTemperature.o built/x86_64-macosx-gfortran/ATMAngle.o built/x86_64-macosx-gfortran/ATMFrequency.o built/x86_64-macosx-gfortran/ATMHumidity.o built/x86_64-macosx-gfortran/ATMMassDensity.o built/x86_64-macosx-gfortran/ATMNumberDensity.o built/x86_64-macosx-gfortran/ATMPercent.o built/x86_64-macosx-gfortran/ATMWaterVaporRadiometer.o built/x86_64-macosx-gfortran/ATMWVRMeasurement.o built/x86_64-macosx-gfortran/ATMType.o built/x86_64-macosx-gfortran/ATMProfile.o built/x86_64-macosx-gfortran/ATMRefractiveIndex.o built/x86_64-macosx-gfortran/ATMRefractiveIndexProfile.o built/x86_64-macosx-gfortran/ATMSkyStatus.o built/x86_64-macosx-gfortran/ATMSpectralGrid.o built/x86_64-macosx-gfortran/ATMError.o
(cd ./built/x86_64-macosx-gfortran && /opt/local/bin/gfortran-mp-13  -dynamiclib -fopenmp   -L/opt/local/lib -Wl,-headerpad_max_install_names -shared -o /opt/local/lib/gildas/x86_64-macosx-gfortran/lib/libatm2009.so -install_name /opt/local/lib/gildas/x86_64-macosx-gfortran/lib/libatm2009.so ATMOpacity.o ATMLength.o ATMInverseLength.o ATMPressure.o ATMTemperature.o ATMAngle.o ATMFrequency.o ATMHumidity.o ATMMassDensity.o ATMNumberDensity.o ATMPercent.o ATMWaterVaporRadiometer.o ATMWVRMeasurement.o ATMType.o ATMProfile.o ATMRefractiveIndex.o ATMRefractiveIndexProfile.o ATMSkyStatus.o ATMSpectralGrid.o ATMError.o  \
	-o /opt/local/var/macports/build/_opt_bblocal_var_buildworker_ports_build_ports_science_gildas/gildas/work/gildas-src-mar24a/integ/x86_64-macosx-gfortran/lib/libatm2009.so -L/opt/local/var/macports/build/_opt_bblocal_var_buildworker_ports_build_ports_science_gildas/gildas/work/gildas-src-mar24a/integ/x86_64-macosx-gfortran/lib -L/opt/local/lib -L/opt/local/Library/Frameworks/Python.framework/Versions/3.11/lib  -lc++  -lm -ldl -install_name @loader_path/../lib/libatm2009.so)
Undefined symbols for architecture x86_64:
  "__ZNKSs7compareEPKc", referenced from:
      __ZN3atm7OpacityC2EdSs in ATMOpacity.o
      __ZN3atm7Opacity4sputEdSs in ATMOpacity.o
      __ZN3atm7Opacity4sgetEdSs in ATMOpacity.o
      __ZNK3atm7Opacity3getESs in ATMOpacity.o
      __ZN3atm6Length4sputEdSs in ATMLength.o
      __ZN3atm6Length4sgetEdSs in ATMLength.o
      __ZN3atm13InverseLength4sputEdSs in ATMInverseLength.o
      ...
  "__ZNKSt9basic_iosIcSt11char_traitsIcEE5widenEc", referenced from:
      __ZN3atm22RefractiveIndexProfile28updateRefractiveIndexProfileENS_6LengthENS_8PressureENS_11TemperatureEdNS_8HumidityES1_ in ATMRefractiveIndexProfile.o
      __ZN3atm22RefractiveIndexProfile16chanIndexIsValidEj in ATMRefractiveIndexProfile.o
      __ZN3atm22RefractiveIndexProfile21spwidAndIndexAreValidEjj in ATMRefractiveIndexProfile.o
      __ZN3atm12SpectralGrid10wrongSpwIdEj in ATMSpectralGrid.o
      __ZN3atm5Error12printMessageESs in ATMError.o
      __ZN3atm5Error6notifyESs in ATMError.o
  "__ZNSo3putEc", referenced from:
      __ZN3atm22RefractiveIndexProfile28updateRefractiveIndexProfileENS_6LengthENS_8PressureENS_11TemperatureEdNS_8HumidityES1_ in ATMRefractiveIndexProfile.o
      __ZN3atm22RefractiveIndexProfile16chanIndexIsValidEj in ATMRefractiveIndexProfile.o
      __ZN3atm22RefractiveIndexProfile21spwidAndIndexAreValidEjj in ATMRefractiveIndexProfile.o
      __ZN3atm12SpectralGrid10wrongSpwIdEj in ATMSpectralGrid.o
      __ZN3atm5Error12printMessageESs in ATMError.o
      __ZN3atm5Error6notifyESs in ATMError.o
  "__ZNSo5flushEv", referenced from:
      __ZN3atm22RefractiveIndexProfile28updateRefractiveIndexProfileENS_6LengthENS_8PressureENS_11TemperatureEdNS_8HumidityES1_ in ATMRefractiveIndexProfile.o
      __ZN3atm22RefractiveIndexProfile16chanIndexIsValidEj in ATMRefractiveIndexProfile.o
      __ZN3atm22RefractiveIndexProfile21spwidAndIndexAreValidEjj in ATMRefractiveIndexProfile.o
      __ZN3atm12SpectralGrid10wrongSpwIdEj in ATMSpectralGrid.o
      __ZN3atm5Error12printMessageESs in ATMError.o
      __ZN3atm5Error6notifyESs in ATMError.o
  "__ZNSo9_M_insertImEERSoT_", referenced from:
      __ZN3atm12SpectralGrid10wrongSpwIdEj in ATMSpectralGrid.o
  "__ZNSs4_Rep10_M_destroyERKSaIcE", referenced from:
      __ZN3atm7OpacityC2EdSs in ATMOpacity.o
      __ZNK3atm7Opacity3getESsSs in ATMOpacity.o
      __ZNK3atm7Opacity3getESs in ATMOpacity.o
      __ZN3atm6LengthC2EdSs in ATMLength.o
      __ZNK3atm6Length3getESsSs in ATMLength.o
      __ZNK3atm6Length3getESs in ATMLength.o
      __ZN3atm13InverseLengthC2EdSs in ATMInverseLength.o
      ...
  "__ZNSs4_Rep20_S_empty_rep_storageE", referenced from:
      __ZN3atm7OpacityC2EdSs in ATMOpacity.o
      __ZNK3atm7Opacity3getESsSs in ATMOpacity.o
      __ZNK3atm7Opacity3getESs in ATMOpacity.o
      __ZN3atm6LengthC2EdSs in ATMLength.o
      __ZNK3atm6Length3getESsSs in ATMLength.o
      __ZNK3atm6Length3getESs in ATMLength.o
      __ZN3atm13InverseLengthC2EdSs in ATMInverseLength.o
      ...
  "__ZNSs6appendEPKcm", referenced from:
      __ZStplIcSt11char_traitsIcESaIcEESbIT_T0_T1_EPKS3_RKS6_ in ATMError.o
  "__ZNSs6appendERKSs", referenced from:
      __ZStplIcSt11char_traitsIcESaIcEESbIT_T0_T1_EPKS3_RKS6_ in ATMError.o
  "__ZNSs6assignEPKcm", referenced from:
      __ZN3atm12SpectralGridC2ENS_9FrequencyE in ATMSpectralGrid.o
      __ZN3atm12SpectralGrid3addEjjNS_9FrequencyES1_ in ATMSpectralGrid.o
      __ZN3atm12SpectralGridC2EjjNS_9FrequencyES1_ in ATMSpectralGrid.o
      __ZN3atm12SpectralGridC2EjjNS_9FrequencyES1_S1_NS_12SidebandSideENS_12SidebandTypeE in ATMSpectralGrid.o
      __ZN3atm12SpectralGrid3addEjjNS_9FrequencyES1_S1_NS_12SidebandSideENS_12SidebandTypeE in ATMSpectralGrid.o
      __ZN3atm12SpectralGridC2EjjPdSs in ATMSpectralGrid.o
      __ZN3atm12SpectralGridC2EjdPdSs in ATMSpectralGrid.o
      ...
  "__ZNSs6assignERKSs", referenced from:
      __ZN3atm22RefractiveIndexProfileC2ERKS0_ in ATMRefractiveIndexProfile.o
      __ZNSt6vectorISsSaISsEEaSERKS1_ in ATMRefractiveIndexProfile.o
      __ZN3atm9SkyStatusC2ERKS0_ in ATMSkyStatus.o
      __ZNSt6vectorISsSaISsEEaSERKS1_ in ATMSkyStatus.o
      __ZN3atm12SpectralGridC2ERKS0_ in ATMSpectralGrid.o
      __ZNSt6vectorISsSaISsEEaSERKS1_ in ATMSpectralGrid.o
      __ZNSt6vectorISsSaISsEE13_M_insert_auxEN9__gnu_cxx17__normal_iteratorIPSsS1_EERKSs in ATMSpectralGrid.o
      ...
  "__ZNSs7reserveEm", referenced from:
      __ZStplIcSt11char_traitsIcESaIcEESbIT_T0_T1_EPKS3_RKS6_ in ATMError.o
  "__ZNSsC1EPKcRKSaIcE", referenced from:
      __ZNK3atm7Opacity3getESsSs in ATMOpacity.o
      __ZNK3atm6Length3getESsSs in ATMLength.o
      __ZNK3atm13InverseLength3getESsSs in ATMInverseLength.o
      __ZNK3atm9Frequency3getESsSs in ATMFrequency.o
      __ZN3atm20WaterVaporRadiometerC2ESt6vectorIjSaIjEE in ATMWaterVaporRadiometer.o
      __ZN3atm20WaterVaporRadiometerC2ESt6vectorIjSaIjEES1_IdSaIdEE in ATMWaterVaporRadiometer.o
      __ZN3atm20WaterVaporRadiometerC2ESt6vectorIjSaIjEES1_INS_7PercentESaIS4_EE in ATMWaterVaporRadiometer.o
      ...
  "__ZNSsC1ERKSs", referenced from:
      __ZN3atm7OpacityC2EdSs in ATMOpacity.o
      __ZNK3atm7Opacity3getESsSs in ATMOpacity.o
      __ZNK3atm7Opacity3getESs in ATMOpacity.o
      __ZN3atm6LengthC2EdSs in ATMLength.o
      __ZNK3atm6Length3getESsSs in ATMLength.o
      __ZNK3atm6Length3getESs in ATMLength.o
      __ZN3atm13InverseLengthC2EdSs in ATMInverseLength.o
      ...
  "__ZNSsD1Ev", referenced from:
      __GLOBAL__I_a in ATMError.o
  "__ZNSt8ios_base4InitC1Ev", referenced from:
      __GLOBAL__I_a in ATMWaterVaporRadiometer.o
      __GLOBAL__I_a in ATMWVRMeasurement.o
      __GLOBAL__I_a in ATMType.o
      __GLOBAL__I_a in ATMProfile.o
      __GLOBAL__I_a in ATMRefractiveIndexProfile.o
      __GLOBAL__I_a in ATMSkyStatus.o
      __GLOBAL__I_a in ATMSpectralGrid.o
      ...
  "__ZNSt8ios_base4InitD1Ev", referenced from:
      __GLOBAL__I_a in ATMWaterVaporRadiometer.o
      __GLOBAL__I_a in ATMWVRMeasurement.o
      __GLOBAL__I_a in ATMType.o
      __GLOBAL__I_a in ATMProfile.o
      __GLOBAL__I_a in ATMRefractiveIndexProfile.o
      __GLOBAL__I_a in ATMSkyStatus.o
      __GLOBAL__I_a in ATMSpectralGrid.o
      ...
  "__ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l", referenced from:
      __ZN3atm22RefractiveIndexProfile28updateRefractiveIndexProfileENS_6LengthENS_8PressureENS_11TemperatureEdNS_8HumidityES1_ in ATMRefractiveIndexProfile.o
      __ZN3atm22RefractiveIndexProfile16chanIndexIsValidEj in ATMRefractiveIndexProfile.o
      __ZN3atm22RefractiveIndexProfile21spwidAndIndexAreValidEjj in ATMRefractiveIndexProfile.o
      __ZN3atm12SpectralGrid10wrongSpwIdEj in ATMSpectralGrid.o
      __ZN3atm5Error12printMessageESs in ATMError.o
      __ZN3atm5Error6notifyESs in ATMError.o
  "__ZSt20__throw_length_errorPKc", referenced from:
      __ZNSt6vectorIN3atm7PercentESaIS1_EE13_M_insert_auxEN9__gnu_cxx17__normal_iteratorIPS1_S3_EERKS1_ in ATMWaterVaporRadiometer.o
      __ZNSt6vectorIdSaIdEE13_M_insert_auxEN9__gnu_cxx17__normal_iteratorIPdS1_EERKd in ATMWaterVaporRadiometer.o
      __ZNSt6vectorIN3atm11TemperatureESaIS1_EE13_M_insert_auxEN9__gnu_cxx17__normal_iteratorIPS1_S3_EERKS1_ in ATMWVRMeasurement.o
      __ZNSt6vectorIdSaIdEE13_M_insert_auxEN9__gnu_cxx17__normal_iteratorIPdS1_EERKd in ATMType.o
      __ZNSt6vectorIN3atm13NumberDensityESaIS1_EE13_M_insert_auxEN9__gnu_cxx17__normal_iteratorIPS1_S3_EERKS1_ in ATMProfile.o
      __ZNSt6vectorIdSaIdEE13_M_insert_auxEN9__gnu_cxx17__normal_iteratorIPdS1_EERKd in ATMProfile.o
      __ZN3atm22RefractiveIndexProfile24mkRefractiveIndexProfileEv in ATMRefractiveIndexProfile.o
      ...
  "__ZSt20__throw_out_of_rangePKc", referenced from:
      __ZN3atm22RefractiveIndexProfileC2ERKS0_ in ATMRefractiveIndexProfile.o
      __ZN3atm22RefractiveIndexProfile13getDryOpacityEj in ATMRefractiveIndexProfile.o
      __ZN3atm22RefractiveIndexProfile17getDryContOpacityEj in ATMRefractiveIndexProfile.o
      __ZN3atm22RefractiveIndexProfile17getO2LinesOpacityEj in ATMRefractiveIndexProfile.o
      __ZN3atm22RefractiveIndexProfile17getCOLinesOpacityEj in ATMRefractiveIndexProfile.o
      __ZN3atm22RefractiveIndexProfile18getN2OLinesOpacityEj in ATMRefractiveIndexProfile.o
      __ZN3atm22RefractiveIndexProfile17getO3LinesOpacityEj in ATMRefractiveIndexProfile.o
      ...
  "__ZSt4cout", referenced from:
      __ZN3atm22RefractiveIndexProfile28updateRefractiveIndexProfileENS_6LengthENS_8PressureENS_11TemperatureEdNS_8HumidityES1_ in ATMRefractiveIndexProfile.o
      __ZN3atm22RefractiveIndexProfile16chanIndexIsValidEj in ATMRefractiveIndexProfile.o
      __ZN3atm22RefractiveIndexProfile21spwidAndIndexAreValidEjj in ATMRefractiveIndexProfile.o
      __ZN3atm12SpectralGrid10wrongSpwIdEj in ATMSpectralGrid.o
      __ZN3atm5Error12printMessageESs in ATMError.o
      __ZN3atm5Error6notifyESs in ATMError.o
ld: symbol(s) not found for architecture x86_64
collect2: error: ld returned 1 exit status

https://build.macports.org/builders/ports-10.8_x86_64-builder/builds/170019/steps/install-port/logs/stdio

Looks like it needs C++17?

Change History (7)

comment:1 Changed 4 weeks ago by bardeau

All the undefined symbols are those from the C++ library (the one associated to the C++ compiler).

The libatm2009.so library created here, and subsequent libraries and programs created later in the build process, have to be linked by the Fortran compiler. The counterpart is that we have to provide in a way or another the path to the C++ library (either with -L/-l options, or with a full path). Unfortunately the piece of Makefile we use say it clearly:

ifeq ($(GAG_COMPILER_CXXKIND),clang++)
  # Apple LLVM: we have to link against libc++. No way to find its correct
  # location, assume default.
  GAG_COMPILER_CXXLIBS = -lc++
else
  # GNU: we have to link against libstdc++. Find its correct location (it
  # can be at non standard place in case of custom compiler)
  GAG_COMPILER_CXXLIBS = $(shell $(GAG_COMPILER_CXXEXE) -print-file-name=libstdc++.$(LIB_CXX_EXT))
endif

If you know a robust way to get the libc++ library location, I can make a fix. Note that there is no issue on Mavericks and newer Mac OS version.

comment:2 Changed 4 weeks ago by kencu (Ken)

on systems < 10.9, /usr/bin/clang++ links c++ code against libstdc++ , not against libc++, unless you tell it otherwise.

so you likely need to manually put -stdlib=libc++ into the cxxflags.

comment:3 in reply to:  2 ; Changed 4 weeks ago by barracuda156

Replying to kencu:

on systems < 10.9, /usr/bin/clang++ links c++ code against libstdc++ , not against libc++, unless you tell it otherwise.

so you likely need to manually put -stdlib=libc++ into the cxxflags.

Did not know that. But why? Apple switched to libc++ starting from 10.7, didn’t it?

comment:4 Changed 4 weeks ago by kencu (Ken)

transition period to libc++.

NB I modified all the macports-clang-N compilers to default to libc++ on 10.7 and 10.8 if the user's system is configured to use libc++ (as they are in macports by default), so the macport-clang-N compilers behave slightly differently than /usr/bin/clang++ and -- more along the lines of what is desired.

comment:5 in reply to:  3 Changed 4 weeks ago by ryandesign (Ryan Carsten Schmidt)

Replying to barracuda156:

so you likely need to manually put -stdlib=libc++ into the cxxflags.

You should not literally write -stdlib=libc++ in the Portfile, of course; you should use -stdlib=${configure.cxx_stdlib} since the user could conceivably change its value in macports.conf and its default differs based on the macOS version.

Did not know that. But why? Apple switched to libc++ starting from 10.7, didn’t it?

Apple started including libc++ in /usr/lib in OS X 10.7 and switched its versions of clang to use it by default in OS X 10.9.

On Mac OS X 10.6, MacPorts installs its own build of libc++ in /usr/lib since Apple didn't provide one, and by default MacPorts uses libc++ on Mac OS X 10.6 and later.

comment:6 Changed 4 weeks ago by barracuda156

I recall Ken mentioned that he had set up his < 10.9 machines to libstdc++ if I am not wrong. That would seem logical in fact and would follow Apple’s own choice. It would also help to see issues which we currently only see on powerpc and therefore fix them.

Why is it not actually done? If clangs can work with libstdc++, what is the stopper?

comment:7 Changed 4 weeks ago by kencu (Ken)

For my /opt/bootstrap miniature macports installations that prove a newer libcurl for macports to build against, I do set them up that way for minimal dependencies. (I also use a modified libcurl port with very few deps, but that is another tale).

In general though -- so far at least -- 10.6 through 10.8 have been the most compatible when they are set up to use clang and libc++ just like 10.9+, as that is the way software is tested out in the world and fixes are done to support that building style.

If you try to install much with those systems set up to libstdc++, I strongly suspect you will see many more build failures that way. For one thing, you will start seeing the same issues that require binwrapping when building with newer gcc versions now.

Note: See TracTickets for help on using tickets.