[MacPorts] #58837: nmap compilation fails

MacPorts noreply at macports.org
Thu Aug 15 07:21:35 UTC 2019


#58837: nmap compilation fails
-----------------------+--------------------
  Reporter:  lemzwerg  |      Owner:  (none)
      Type:  defect    |     Status:  closed
  Priority:  Normal    |  Milestone:
 Component:  ports     |    Version:
Resolution:  wontfix   |   Keywords:  lion
      Port:  nmap      |
-----------------------+--------------------

Comment (by kencu):

 Here is the issue:
 {{{
 :info:build /usr/bin/clang++ -L/opt/local/lib
 -Wl,-headerpad_max_install_names -arch x86_64 -L/opt/local/lib -Lnbase
 -Lnsock/src/   -o nmap charpool.o FingerPrintResults.o FPEngine.o
 FPModel.o idle_scan.o MACLookup.o nmap_dns.o nmap_error.o nmap.o
 nmap_ftp.o NmapOps.o NmapOutputTable.o nmap_tty.o osscan2.o osscan.o
 output.o payload.o portlist.o portreasons.o protocols.o scan_engine.o
 scan_engine_connect.o scan_engine_raw.o scan_lists.o service_scan.o
 services.o NewTargets.o TargetGroup.o Target.o targets.o tcpip.o timing.o
 traceroute.o utils.o xml.o nse_main.o nse_utility.o nse_nsock.o nse_dnet.o
 nse_fs.o nse_nmaplib.o nse_debug.o nse_pcrelib.o nse_lpeg.o nse_openssl.o
 nse_ssl_cert.o nse_libssh2.o nse_zlib.o main.o -lnsock -lnbase -lpcre
 -lpcap libssh2/lib/libssh2.a -lssl -lcrypto -lz libnetutil/libnetutil.a
 ./libdnet-stripped/src/.libs/libdnet.a ./liblua/liblua.a
 ./liblinear/liblinear.a -lm
 :info:build Undefined symbols for architecture x86_64:
 :info:build   "std::__1::basic_string<char, std::__1::char_traits<char>,
 std::__1::allocator<char> >::find_first_of(char const*, unsigned long,
 unsigned long) const", referenced from:
 :info:build       __ZL15filename_to_urlPKc in NmapOps.o
 }}}

 when `nmap` builds and links, it does not specify a `stdlib` setting on
 the build line. By default, `clang` on systems < 10.9 examines the build
 and link lines for a `-stdlib` setting, and if none is found, `clang`
 defaults to adding `-stdlib=libstdc++`. That causes the build to fail
 because it does not find all the proper symbols that it is looking for, as
 noted by the `std::__1:*` errors.

 The proper fix is to force the `stdlib` onto the build and link lines.
 However, this is a bit of a PITA.

 Another fix is to make `clang` default to adding `-stdlib=libc++` on your
 `libc++` system which is configured that way. This matches the behaviour
 of all the newer systems, 10.9 and newer.

 I changed `clang-5.0` and newer to do exactly that on systems configured
 to used `libc++` in their macports.conf, like yours. It can be seen by the
 default variants for clang-5.0, which, on your system, should be
 `clang-5.0 +analyzer +defaultlibcxx +libstdcxx`.

 The `+defaultlibcxx` variant makes `clang-5.0` add `-stdlib=libc++` if
 none is specified, rather than `-stdlib=libstdc++`, which is what you want
 it to do on your system.

 SHORT story. If your `clang-5.0` is installed correctly, with the
 `+defaultlibcxx` variant on your system, building `nmap` with `clang-5.0`
 should work correctly, ie do this:
 {{{
 sudo port clean nmap
 sudo port -v install nmap configure.compiler=macports-clang-5.0
 }}}

 To add the `-stdlib` to the build line instead, you would need to dig in a
 bit to the build. `botan` does a fix for this, with a patch and then a
 reinplace:
 {{{
 # respect MacPorts configure values
 patchfiles-append   patch-compiler_flags.diff \
                     patch-fix-install-with-destdir.diff \
                     patch-python_exe.diff \
                     patch-map_anon.diff

 post-patch {
     reinplace -W ${worksrcpath}/src/build-data/cc \
         "s|__MACPORTS_CXX_STDLIB__|${configure.cxx_stdlib}|g" \
         clang.txt
 }

 }}}

 alternatively, sometimes you can just add it to the build line by adding a
 `configure.cxxflags-append` -- caution though, `-stdlib=XYZ` is only
 supported by `clang`, so you have to test to make sure that the build
 compiler is clang if you do this.

-- 
Ticket URL: <https://trac.macports.org/ticket/58837#comment:3>
MacPorts <https://www.macports.org/>
Ports system for macOS


More information about the macports-tickets mailing list