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

Building with alternate compiler/sysroot causes failure internal to make process #2800

Open
cross-cisco opened this issue Mar 13, 2024 · 1 comment
Labels

Comments

@cross-cisco
Copy link

Describe the bug
When building with an unusual compilation toolset, the generation of NMAP_VERSION in the root Makefile can fail.

To Reproduce
'CPP=/usr/bin/aarch64-linux/aarch64-linux-cpp --sysroot=/opt/aarch64-linux-sysroot' 'CC=/usr/bin/aarch64-linux/aarch64-linux-gcc --sysroot=/opt/aarch64-linux-sysroot' 'LDFLAGS=--sysroot=/opt/aarch64-linux-sysroot' 'CXX=/usr/bin/aarch64-linux/aarch64-linux-g++ --sysroot=/opt/aarch64-linux-sysroot' ./configure
make
Produces:

bf47efe89ec2:/data/cross/builddir/product-arm/work/nmap-7.94 > make
In file included from <command-line>:31:
./nmap.h:91:10: fatal error: assert.h: No such file or directory
   91 | #include <assert.h>
      |          ^~~~~~~~~~
compilation terminated.
/usr/bin/aarch64-linux/aarch64-linux-g++ --sysroot=/opt/aarch64-linux-sysroot -MM -I./liblinear -I./liblua -I./libdnet-stripped/include -I./libssh2/include  -I./nbase -I./nsock/include -DHAVE_CONFIG_H -DNMAP_PLATFORM=\"aarch64-unknown-linux-gnu\" -DNMAPDATADIR=\"/data/cross/builddir/product-arm/nmap/share/nmap\" -D_FORTIFY_SOURCE=2 charpool.cc FingerPrintResults.cc FPEngine.cc FPModel.cc idle_scan.cc MACLookup.cc main.cc nmap.cc nmap_dns.cc nmap_error.cc nmap_ftp.cc NmapOps.cc NmapOutputTable.cc nmap_tty.cc osscan2.cc osscan.cc output.cc payload.cc portlist.cc portreasons.cc protocols.cc scan_engine.cc scan_engine_connect.cc scan_engine_raw.cc scan_lists.cc service_scan.cc services.cc string_pool.cc Target.cc NewTargets.cc TargetGroup.cc targets.cc tcpip.cc timing.cc traceroute.cc utils.cc xml.cc nse_main.cc nse_utility.cc nse_nsock.cc nse_db.cc nse_dnet.cc nse_fs.cc nse_nmaplib.cc nse_debug.cc nse_pcrelib.cc nse_lpeg.cc nse_openssl.cc nse_ssl_cert.cc nse_libssh2.cc nse_zlib.cc > makefile.dep

Notice that before make even invokes the first target, it produces an error, but continues regardless. Testing shows that for me, the make variable NMAP_VERSION ends up containing #1./nmap.h1 instead of 5.94.

Expected behavior
Running without error

Version info (please complete the following information):

  • OS: Linux 5.15.0
  • (referencing build of 5.94. --version and --iflist output not relevant)

Additional context
This is occurring for me in a cross-build environment. We have specified values for CC,CXX,CPP in the environment when running configure. This puts these in the right place for the later build.
However, the top of Makefile includes a $(shell) that uses $(CPP) directly, which fails because it isn't using the CPP given in configure's environment

Fix
Fixes include:

  • Add CPP = @CPP@ as the first line in Makefile
  • Replace the $(CPP) in the $(shell) command with @CPP@

These have both been tested and do not produce the failure originally seen. The sensible addition of CPP = @CPP@ with CC and CXX at lines 23-24 does not suffice, as the variable is referenced before it's set. If NMAP_VERSION is initialized later in the top portion of the Makefile, that would likely also work.

@cross-cisco
Copy link
Author

Hey all. PR is up, let me know if that's adequate or if you want a different solution. Thank you.

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

No branches or pull requests

1 participant