New Compiler error on mac

I am trying to build the latest version of panda3d on my mac. This was working as of August of this year. However, I did have an upgrade of Apple’s XCode lately and I wonder if that is the issue. In any case it fails about 45% into the build with this error.

The following command returned a non-zero value: clang++ -std=gnu++11 -ftemplate-depth-70 -fPIC -c -o built/tmp/p3cocoadisplay_composite1.o -Ibuilt/tmp -Ibuilt/include -Ithirdparty/darwin-libs-a/eigen/include -Ithirdparty/darwin-libs-a/nvidiacg/include -Ipanda/src/cocoadisplay -fvisibility=hidden -Wno-deprecated-declarations -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX11.3.sdk -mmacosx-version-min=10.9 -stdlib=libc++ -pthread -fno-exceptions -U__EXCEPTIONS -msse2 -fno-strict-aliasing -fno-unsafe-math-optimizations -ggdb -D_DEBUG -Wall -Wno-unused-function -Wno-reorder -DBUILDING_PANDAGL panda/src/cocoadisplay/p3cocoadisplay_composite1.mm

Could you share the error message, not just the failing command?

[ 48%] Building Objective-C++ object built/tmp/p3cocoadisplay_composite1.o
clang: error: unable to execute command: Segmentation fault: 11
clang: error: clang frontend command failed due to signal (use -v to see invocation)
Apple clang version 13.0.0 (clang-1300.0.29.3)
Target: x86_64-apple-darwin20.6.0
Thread model: posix
InstalledDir: /Library/Developer/CommandLineTools/usr/bin
clang: note: diagnostic msg:


PLEASE ATTACH THE FOLLOWING FILES TO THE BUG REPORT:
Preprocessed source(s) and associated run script(s) are located at:
clang: note: diagnostic msg: /var/folders/ym/6z2jmkz95ds6_qblmpkhly9c0000gn/T/p3cocoadisplay_composite1-fff8e2.mm
clang: note: diagnostic msg: /var/folders/ym/6z2jmkz95ds6_qblmpkhly9c0000gn/T/p3cocoadisplay_composite1-fff8e2.sh
clang: note: diagnostic msg: Crash backtrace is located in
clang: note: diagnostic msg: /Users/paustian/Library/Logs/DiagnosticReports/clang__.crash
clang: note: diagnostic msg: (choose the .crash file that corresponds to your crash)
clang: note: diagnostic msg:


Storing dependency cache.
Elapsed Time: 14 sec
The following command returned a non-zero value: clang++ -std=gnu++11 -ftemplate-depth-70 -fPIC -c -o built/tmp/p3cocoadisplay_composite1.o -Ibuilt/tmp -Ibuilt/include -Ithirdparty/darwin-libs-a/eigen/include -Ithirdparty/darwin-libs-a/nvidiacg/include -Ipanda/src/cocoadisplay -fvisibility=hidden -Wno-deprecated-declarations -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX11.3.sdk -mmacosx-version-min=10.9 -stdlib=libc++ -pthread -fno-exceptions -U__EXCEPTIONS -msse2 -fno-strict-aliasing -fno-unsafe-math-optimizations -ggdb -D_DEBUG -Wall -Wno-unused-function -Wno-reorder -DBUILDING_PANDAGL panda/src/cocoadisplay/p3cocoadisplay_composite1.mm

This looks like a compiler bug. Perhaps try removing 11.3 from the list of SDKs in SdkLocateMacOSX in makepandacore.py. Either that or it might be necessary to downgrade XCode.

Thanks for the help. I am trying it now. Commenting out that line didn’t help. So I am trying to downgrade now. I think XCode 12.5.1 is fine?

Moving back to 12.5.1 fixed the problem. Thanks for your help rdb

I believe this problem is now worked around in Panda; it was caused by a bug in Clang that caused a crash when a certain compiler flag was passed to the Objective-C++ compiler.

Here is my build command. Any idea what the flag could be?

/usr/bin/clang++ -g /pathtodirectory/panda3d/pandatool/src/bam/bamInfo.cxx -std=c++11 -I /pathtodirectory/panda3d/built/include -L /pathtodirectory/panda3d/built/lib -lp3framework -lpanda -lpandaexpress -lp3dtoolconfig -lp3dtool -lp3direct -o /pathtodirectory/panda3d/pandatool/src/bam/

These were the flags that caused the issue; clang crashes when they are used when compiling .mm files.

makepanda now no longer passes them in when compiling .mm files.

This is the build command I am trying to use:

/usr/bin/clang++ -g /Users/paustian/Documents/ComputingProjects/panda3d/pandatool/src/bam/bamListTextures.cxx -std=c++11 -I /Users/paustian/Documents/ComputingProjects/panda3d/built/include -L /Users/paustian/Documents/ComputingProjects/panda3d/built/lib -lp3framework -lpanda -lpandaexpress -lp3dtoolconfig -lp3dtool -lp3direct -o /Users/paustian/Documents/ComputingProjects/panda3d/built/bin/bamListTextures

I think I am missing some context here. The original problem in this thread was with a compiler crash trying to compile certain .mm files of the Panda codebase due to certain flags, but those flags aren’t present in your command (and it isn’t related to compiling .mm files).

Are you also getting a compiler crash with this command? Or some error message? Please share the message if so.

Yeah, sorry about that. I was not being clear. I am trying to work on this issue. As a first step I wanted to step through the code for EggListTextures.cxx and compile it to make sure I could building it. Here is the verbose version of the errors I am getting:

Executing task: C/C++: clang++ build active file 

Starting build...
/usr/bin/clang++ -g /Users/paustian/Documents/ComputingProjects/panda3d/pandatool/src/eggprogs/eggListTextures.cxx -std=c++11 -I /Users/paustian/Documents/ComputingProjects/panda3d/built/include -L /Users/paustian/Documents/ComputingProjects/panda3d/built/lib -lp3framework -lpanda -lpandaexpress -lp3dtoolconfig -lp3dtool -lp3direct -v -o /Users/paustian/Documents/ComputingProjects/panda3d/built/bin/eggListTextures
Apple clang version 12.0.5 (clang-1205.0.22.11)
Target: x86_64-apple-darwin20.6.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin

 "/Applications/Xcode.app/Contents/Developer/Toolcha
ins/XcodeDefault.xctoolchain/usr/bin/clang" -cc1 -triple x86_64-apple-macosx11.0.0 -Wdeprecated-objc-isa-usage -Werror=deprecated-objc-isa-usage -Werror=implicit-function-declaration -emit-obj -mrelax-all -disable-free -disable-llvm-verifier -discard-value-names -main-file-name eggListTextures.cxx -mrelocation-model pic -pic-level 2 -mframe-pointer=all -fno-strict-return -fno-rounding-math -munwind-tables -target-sdk-version=11.3 -fvisibility-inlines-hidden-static-local-var -target-cpu penryn -debug-info-kind=standalone
 -dwarf-version=4 -debugger-tuning=lldb -target-linker-version 650.9 -v -resource-dir /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/12.0.5 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk -I /Users/paustian/Documents/ComputingProjects/panda3d/built/include -I/usr/local/include -stdlib=libc++ 
-internal-isystem /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/v1 -internal-isystem /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/local/include -internal-isystem /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/12.0.5/include -internal-externc-isystem /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include -internal-externc-isystem /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include -Wno-reorder-init-list -Wno-implicit-int-float-conversion -Wno-c99-designator -Wno-final-dtor-non-final-class
 -Wno-extra-semi-stmt -Wno-misleading-indentation -Wno-quoted-include-in-framework-header -Wno-implicit-fallthrough -Wno-enum-enum-conversion -Wno-enum-float-conversion -Wno-elaborated-enum-base -std=c++11 -fdeprecated-macro -fdebug-compilation-dir /Users/paustian/Documents/ComputingProjects/panda3d -ferror-limit 19 -stack-protector 1 -fstack-check -mdarwin-stkchk-strong-link
 -fblocks -fencode-extended-block-signature -fregister-global-dtors-with-atexit -fgnuc-version=4.2.1 -fcxx-exceptions -fexceptions -fmax-type-align=16 -fcommon -clang-vendor-feature=+disableNonDependentMemberExprInCurrentInstantiation -fno-odr-hash-protocols
 -mllvm -disable-aligned-alloc-awareness=1 -o /var/folders/ym/6z2jmkz95ds6_qblmpkhly9c0000gn/T/eggListTextures-ac6497.o -x c++ /Users/paustian/Documents/ComputingProjects/panda3d/pandatool/src/eggprogs/eggListTextures.cxx

clang -cc1 version 12.0.5 (clang-1205.0.22.11) default target x86_64-apple-darwin20.6.0

ignoring nonexistent directory "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/local/include"

ignoring nonexistent directory "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/Library/Frameworks"
#include "..." search starts here:
#include <...> search starts here:
 /Users/paustian/Documents/ComputingProjects/panda3d/built/include
 /usr/local/include
 /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/v1
 /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/12.0.5/include
 /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include
 /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include
 /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks (framework directory)
End of search list.

 "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ld" -demangle -lto_library /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/libLTO.dylib -no_deduplicate -dynamic -arch x86_64 -platform_version macos 11.0.0 11.3 -syslibroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk -o /Users/paustian/Documents/ComputingProjects/panda3d/built/bin/eggListTextures -L/Users/paustian/Documents/ComputingProjects/panda3d/built/lib -L/usr/local/lib
 /var/folders/ym/6z2jmkz95ds6_qblmpkhly9c0000gn/T/eggListTextures-ac6497.o -lp3framework -lpanda -lpandaexpress -lp3dtoolconfig -lp3dtool -lp3direct -lc++ -lSystem /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/12.0.5/lib/darwin/libclang_rt.osx.a

Undefined symbols for architecture x86_64:
  "ProgramBase::handle_args(pdeque<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >&)", referenced from:
      vtable for EggBase in eggListTextures-ac6497.o

  "ProgramBase::post_command_line()", referenced from:
      vtable for EggBase in eggListTextures-ac6497.o
  "ProgramBase::set_program_brief(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&)", referenced from:
      EggListTextures::EggListTextures() in eggListTextures-ac6497.o
      EggListTextures::EggListTextures() in eggListTextures-ac6497.o
  "ProgramBase::parse_command_line(int, char**, bool)", referenced from:
      _main in eggListTextures-ac6497.o
      vtable for EggListTextures in eggListTextures-ac6497.o
      construction vtable for EggReader-in-EggListTextures in eggListTextures-ac6497.o
      vtable for EggBase in eggListTextures-ac6497.o
  "ProgramBase::set_program_description(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&)", referenced from:
      EggListTextures::EggListTextures() in eggListTextures-ac6497.o
      EggListTextures::EggListTextures() in eggListTextures-ac6497.o
  "ProgramBase::~ProgramBase()", referenced from:
      EggBase::~EggBase() in eggListTextures-ac6497.o
  "EggSingleBase::as_writer()", referenced from:
      vtable for EggListTextures in eggListTextures-ac6497.o
      construction vtable for EggReader-in-EggListTextures in eggListTextures-ac6497.o
  "EggSingleBase::EggSingleBase()", referenced from:
      EggListTextures::EggListTextures() in eggListTextures-ac6497.o

  "PointerToBase<EggTexture>::~PointerToBase()", referenced from:
      PointerTo<EggTexture>::~PointerTo() in eggListTextures-ac6497.o
  "EggTextureCollection::sort_by_basename()", referenced from:
      EggListTextures::run() in eggListTextures-ac6497.o
  "EggTextureCollection::find_used_textures(EggNode*)", referenced from:
      EggListTextures::run() in eggListTextures-ac6497.o
  "EggTextureCollection::collapse_equivalent_textures(int, pmap<PointerTo<EggTexture>, PointerTo<EggTexture>, std::__1::less<PointerTo<EggTexture> > >&)", referenced from:
      EggListTextures::run() in eggListTextures-ac6497.o

  "EggTextureCollection::EggTextureCollection()", referenced from:
      EggListTextures::run() in eggListTextures-ac6497.o
  "EggTextureCollection::~EggTextureCollection()", referenced from:
      EggListTextures::run() in eggListTextures-ac6497.o
  "EggReader::handle_args(pdeque<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >&)", referenced from:

      vtable for EggListTextures in eggListTextures-ac6497.o
      construction vtable for EggReader-in-EggListTextures in eggListTextures-ac6497.o
  "EggReader::do_reader_options()", referenced from:
      EggListTextures::run() in eggListTextures-ac6497.o
  "EggReader::post_command_line()", referenced from:

      vtable for EggListTextures in eggListTextures-ac6497.o
      construction vtable for EggReader-in-EggListTextures in eggListTextures-ac6497.o
  "EggReader::pre_process_egg_file()", referenced from:
      vtable for EggListTextures in eggListTextures-ac6497.o
      construction vtable for EggReader-in-EggListTextures in eggListTextures-ac6497.o
  "EggReader::as_reader()", referenced from:
      vtable for EggListTextures in eggListTextures-ac6497.o
      construction vtable for EggReader-in-EggListTextures in eggListTextures-ac6497.o

  "EggReader::EggReader()", referenced from:
      EggListTextures::EggListTextures() in eggListTextures-ac6497.o
      EggListTextures::EggListTextures() in eggListTextures-ac6497.o
  "PointerTo<EggTexture>::operator->() const", referenced from:
      EggListTextures::run() in eggListTextures-ac6497.o

  "typeinfo for ProgramBase", referenced from:
      typeinfo for EggBase in eggListTextures-ac6497.o
  "typeinfo for EggReader", referenced from:
      construction vtable for EggReader-in-EggListTextures in eggListTextures-ac6497.o
      typeinfo for EggListTextures in eggListTextures-ac6497.o

  "VTT for EggReader", referenced from:
      EggReader::~EggReader() in eggListTextures-ac6497.o
  "vtable for EggSingleBase", referenced from:
      EggSingleBase::~EggSingleBase() in eggListTextures-ac6497.o

  NOTE: a missing vtable usually means the first non-inline virtual member function has no definition.
  "virtual thunk to EggReader::handle_args(pdeque<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >&)", referenced from:
      vtable for EggListTextures in eggListTextures-ac6497.o
      construction vtable for EggReader-in-EggListTextures in eggListTextures-ac6497.o

  "virtual thunk to EggReader::post_command_line()", referenced from:
      vtable for EggListTextures in eggListTextures-ac6497.o
      construction vtable for EggReader-in-EggListTextures in eggListTextures-ac6497.o
  "virtual thunk to EggReader::as_reader()", referenced from:

      vtable for EggListTextures in eggListTextures-ac6497.o
      construction vtable for EggReader-in-EggListTextures in eggListTextures-ac6497.o

ld: symbol(s) not found for architecture x86_64

clang: error: linker command failed with exit code 1 (use -v to see invocation)

Build finished with error(s).

I think you’re missing to link with some libraries, like -lp3eggbase. See COMMON_EGG2X_LIBS in makepanda.py, those are the libraries being pulled in when building egg-list-textures.

For what it’s worth, I think we don’t need a separate bam-list-textures utility, this functionality could just be added to bam-info as a separate flag.

I will try that change. Just to make sure I am understanding, you would add the -baminfo to the eggListTextures.cxx tool?

No, I would add a -lstex (or -list-textures, whatever) flag to the bam-info (bamInfo.cxx) tool.

Just a follow up. I got this to work. Two modifications were necessary

  1. You must build panda3d first using the makepanda.py script. This creates all the libraries you need for any work you are doing. Here is the command I used:
    makepanda.py --everything --no-fmod --optimize=1

I have this set up in VSCode as a configuration like this:

{
            "name": "Build Panda3D",
            "type": "python",
            "request": "launch",
            "program": "${workspaceFolder}/makepanda/makepanda.py",
            "console": "integratedTerminal",
            "args": [
                "--everything",
                "--no-fmod",
                "--optimize=1"
            ]
}

The command failed at 48% due to a clang++ bug with Xcode 13. I had to downgrade my Xcode to 12.5 to fix it.

  1. You need to link a string of libraries when you build any C++ file for panda3d. Here is the command that worked for me:
    /usr/bin/clang++ -g /Users/paustian/Documents/ComputingProjects/panda3d/pandatool/src/bam/bamInfo.cxx -std=c++11 -I /Users/paustian/Documents/ComputingProjects/panda3d/built/include -L /Users/paustian/Documents/ComputingProjects/panda3d/built/lib -lp3framework -lpanda -lpandaexpress -lp3dtoolconfig -lp3dtool -lp3direct -lp3eggbase -lp3progbase -lp3converter -lp3pandatoolbase -lpandaegg -v -o /Users/paustian/Documents/ComputingProjects/panda3d/built/bin/bamInfo

In addition, it took me a bit to notice that the library name was different than the option in the command (lib3progbase vs -l3progbase). It is convenient to set up a Build Task in VSCode (this goes in tasks.json):

{
            "type": "cppbuild",
            "label": "C/C++: clang++ build active file",
            "command": "/usr/bin/clang++",
            "args": [
                "-g",
                "${file}",
                "-std=c++11",
                "-I",
                "/Users/paustian/Documents/ComputingProjects/panda3d/built/include",
                "-L",
                "/Users/paustian/Documents/ComputingProjects/panda3d/built/lib",
                "-lp3framework",
                "-lpanda",
                "-lpandaexpress",
                "-lp3dtoolconfig",
                "-lp3dtool",
                "-lp3direct",
                "-lp3eggbase",
                "-lp3progbase",
                "-lp3converter",
                "-lp3pandatoolbase",
                "-lpandaegg",
                "-v",
                "-o",
                "/Users/paustian/Documents/ComputingProjects/panda3d/built/bin/${fileBasenameNoExtension}"
            ],
            "options": {
                "cwd": "${workspaceFolder}"
            },
            "problemMatcher": [
                "$gcc"
            ],
            "group": {
                "kind": "build",
                "isDefault": true
            },
            "detail": "compiler: /usr/bin/clang++"
}