[Lldb-commits] [PATCH] D151570: Fix Build error on Mac M1 : error: use of undeclared identifier 'getopt_long_only'; did you mean 'getopt_long'?

Nicklas Boman via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Fri May 26 16:36:16 PDT 2023


smurfd added a comment.

Hey, yeah that compiles.
Im using the standard macos clang ,for Ventura 13.4, xcode 14.3

  $ gcc -v
  Apple clang version 14.0.3 (clang-1403.0.22.14.1)
  Target: arm64-apple-darwin22.5.0
  Thread model: posix
  InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin

this is the way i built llvm from git main from `https://github.com/llvm/llvm-project`

  $ rm -rf build && mkdir build && cd build
  $ cmake -DLLVM_ENABLE_PROJECTS="bolt;clang;clang-tools-extra;compiler-rt;lld;lldb;mlir;openmp;polly;flang" -DCMAKE_BUILD_TYPE=Release -DCMAKE_CXX_FLAGS="-D_GLIBCXX_HAVE_ENOTRECOVERABLE=1 -DENOTRECOVERABLE=98" -G "Unix Makefiles" -DCMAKE_INSTALL_PREFIX=$HOME/code/.build/llvm-dev -Bbuild -DLLVM_ENABLE_RUNTIMES="libunwind;libcxxabi;pstl;libcxx" ../llvm
  $ make -j8 -Cbuild

after the error i apply this patch and the build finishes.

im using this checkout : dd16cd731dfb4746a351380edc848199cf9631e8 <https://reviews.llvm.org/rGdd16cd731dfb4746a351380edc848199cf9631e8> (have also now tried main at the time of writing : a419ec4f256d279c91746a3962dd6dd2da45c304 <https://reviews.llvm.org/rGa419ec4f256d279c91746a3962dd6dd2da45c304>) with the same error

  [ 65%] Built target llvm-tapi-diff
  [ 65%] Building CXX object lib/DebugInfo/PDB/CMakeFiles/LLVMDebugInfoPDB.dir/PDB.cpp.o
  /Users/hellbeard/code/_misc/llvm-project/lldb/source/Host/common/OptionParser.cpp:46:10: error: use of undeclared identifier 'getopt_long_only'; did you mean 'getopt_long'?
    return getopt_long_only(argv.size() - 1, argv.data(), opt_cstr.c_str(),
           ^~~~~~~~~~~~~~~~
           getopt_long
  /opt/pkg/include/getopt.h:62:5: note: 'getopt_long' declared here
  int getopt_long(int, char * const *, const char *,
      ^
  1 error generated.
  make[2]: *** [tools/lldb/source/Host/CMakeFiles/lldbHost.dir/common/OptionParser.cpp.o] Error 1
  make[2]: *** Waiting for unfinished jobs....


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D151570/new/

https://reviews.llvm.org/D151570



More information about the lldb-commits mailing list