Undefined symbols SystemRuntimeMacOSX::Initialize and SystemRuntimeMacOSX::Terminate - c++

I'm trying to build LLDB as part of Clang/LLVM. LLVM, Clang, Compiler-RT and Extras build OK. However, LLVM has an issue when building with the other components.
The directory structure is set up according to LLVM/Clang/LLDB instructions. The docs on LLDB are located at Building LLDB. Below was run from the build directory, which lies next to the llvm directory (llvm is where all sources were unpacked):
$ cd build
$ ../llvm/configure --enable-optimized --enable-cxx11 --enable-libcpp --prefix=/usr/local
...
$ make -j4
...
llvm[4]: Compiling ARM_DWARF_Registers.cpp for Release+Asserts build
llvm[4]: Compiling KQueue.cpp for Release+Asserts build
llvm[4]: Compiling PseudoTerminal.cpp for Release+Asserts build
llvm[4]: Compiling Range.cpp for Release+Asserts build
llvm[4]: Compiling SharingPtr.cpp for Release+Asserts build
llvm[4]: Compiling StringExtractor.cpp for Release+Asserts build
llvm[4]: Compiling StringExtractorGDBRemote.cpp for Release+Asserts build
llvm[4]: Compiling TimeSpecTimeout.cpp for Release+Asserts build
llvm[4]: Building Release+Asserts Archive Library liblldbUtility.a
llvm[3]: Linking Release+Asserts Shared Library liblldb.dylib
Undefined symbols for architecture x86_64:
"SystemRuntimeMacOSX::Initialize()", referenced from:
lldb_private::Initialize() in liblldbInitAndLog.a(lldb.o)
"SystemRuntimeMacOSX::Terminate()", referenced from:
lldb_private::Terminate() in liblldbInitAndLog.a(lldb.o)
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[3]: *** [/Users/jwalton/Clang-3.4.2/build/Release+Asserts/lib/liblldb.dylib] Error 1
make[2]: *** [all] Error 1
make[1]: *** [all] Error 1
make: *** [all] Error 1
EDIT: following Matt's instructions below, I was able to avoid Undefined symbols SystemRuntimeMacOSX::Initialize and SystemRuntimeMacOSX::Terminate. But the build still dies with:
llvm[4]: Compiling ARM_DWARF_Registers.cpp for Release+Asserts build
llvm[4]: Compiling KQueue.cpp for Release+Asserts build
llvm[4]: Compiling PseudoTerminal.cpp for Release+Asserts build
llvm[4]: Compiling Range.cpp for Release+Asserts build
llvm[4]: Compiling SharingPtr.cpp for Release+Asserts build
llvm[4]: Compiling StringExtractor.cpp for Release+Asserts build
llvm[4]: Compiling StringExtractorGDBRemote.cpp for Release+Asserts build
llvm[4]: Compiling TimeSpecTimeout.cpp for Release+Asserts build
llvm[4]: Building Release+Asserts Archive Library liblldbUtility.a
make[3]: *** No rule to make target `/Users/jwalton/Clang-3.4.2/build/Release+Asserts/lib/liblldbPluginSystemRuntimeMacOSX.a',
needed by `/Users/jwalton/Clang-3.4.2/build/Release+Asserts/lib/liblldb.dylib'. Stop.
The odd thing is, lldbPluginSystemRuntimeMacOSX is handled the same as other plugins like lldbPluginProcessMachCore. The same directives appear in the same places like Cmake.txt.
The host platform is OS X 10.8.5, x64, fully patched. Xcode version is 5.1.1 (5B1008) (which is the latest).
Does anyone know what magical steps I should perform to get lldb to compile with LLVM and Clang?
100 BOUNTY EDIT: There's a pastebin with my recipe in a shell script at Clang 3.4.2 recipe. The recipe uses Missing-Makefile, and Matt provides it below. The recipe patches the makefile, so you won't need to do it manually.
150 BOUNTY EDIT: Cos' answer was the final step. This question need both Matt's answer and Cos' answer. Cos provided an updated recipe. Its available at Clang 3.4.2 Recipe (Final).

You need to add following patch to your script:
sed -i '' '\|DIRS += Process/mach-core|a\
DIRS += SystemRuntime/MacOSX\
' llvm/tools/lldb/source/Plugins/Makefile
Your updated recipe

I believe that Jim's advice above is probably the best option. But, I also experienced this problem attempting to build llvm+clang+lldb 3.4.
I narrowed the problem down to one particular plugin, specific to OS X, not building at all via Make. This was a build system bug, fixed by this commit:
https://github.com/llvm-mirror/lldb/commit/7a53199e140843235d2bd2b12182ceb764419c8a
You can use the commit above as a guide. Only two changes actually need to be made to build successfully. I just patched my local copy.
lldb/lib/Makefile: "lldbPluginSystemRuntimeMacOSX.a" needs to be added after line 98
lldb/source/Plugins/SystemRuntime/MacOSX/Makefile needs to be created with the following contents:
##===- source/Plugins/SystemRuntime/MacOSX/Makefile ---------*- Makefile -*-===##
#
# The LLVM Compiler Infrastructure
#
# This file is distributed under the University of Illinois Open Source
# License. See LICENSE.TXT for details.
#
##===----------------------------------------------------------------------===##
LLDB_LEVEL := ../../../..
LIBRARYNAME := lldbPluginSystemRuntimeMacOSX
BUILD_ARCHIVE = 1
include $(LLDB_LEVEL)/Makefile
With all this done, I was able to finish the build and get a functioning version of liblldb.dylib, which is what I was after. Hope this helps!

I generally build using the Xcode project on MacOS X. Just get the lldb sources, and do:
cd lldb
xcodebuild -configuration Debug
or if you want to debug the Clang side of things as well:
xcodebuild -configuration DebugClang
You don't even need to get the llvm sources, the Xcode project will check them out for you if they aren't present (but won't override the version you have it you want to try to build against a branch or whatever...)
TOT lldb is building fine for me right now.
There are other folks on the lldb-dev mailing list who do use the Makefile build, if you want to build it this way for some reason, you might ask there.some

Related

cmake on Mac with ARM M1 is running linker with x86_64 architecture instead of arm64

I am trying to compile glfw from source on Mac with M1 arm64 processor, and while running the linker, cmake strangely is trying to link the project for x86_64 architecture, while the binaries were built for arm64.
I clone the project, create build folder named cmake-build-debug, generate build system in it with the Makefile etc. as follows:
git clone https://github.com/glfw/glfw.git
cd glfw
mkdir cmake-build-debug
cd cmake-build-debug
cmake -S .. -B . -DCMAKE_BUILD_TYPE=Debug -DCMAKE_HOST_SYSTEM_PROCESSOR=arm64 -DCMAKE_SYSTEM_PROCESSOR=arm64
This works fine. But now that I build it with make or cmake --config Debug --build ., the .o binaries are generated perfectly fine, but linker script is incorrectly invoked by cmake with x86_64 target architecture for some reason:
-- Could NOT find Doxygen (missing: DOXYGEN_EXECUTABLE)
-- Including Cocoa support
-- Configuring done
-- Generating done
-- Build files have been written to: /Users/burkov/Documents/Projects/open-source/glfw/cmake-build-debug
[ 47%] Built target glfw
Scanning dependencies of target wave
[ 50%] Linking C executable wave.app/Contents/MacOS/wave
ld: warning: ignoring file CMakeFiles/wave.dir/wave.c.o, building for macOS-x86_64 but attempting to link with file built for unknown-arm64
ld: warning: ignoring file ../src/libglfw3.a, building for macOS-x86_64 but attempting to link with file built for macOS-arm64
Undefined symbols for architecture x86_64:
"_main", referenced from:
implicit entry/start for main executable
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[2]: *** [examples/wave.app/Contents/MacOS/wave] Error 1
make[1]: *** [examples/CMakeFiles/wave.dir/all] Error 2
make: *** [all] Error 2
I look at the failing Makefile in glfw/cmake-build-debug/examples/CMakeFiles/wave.dir/build.make and see the line, where cmake is crashing:
cd /Users/me/Documents/Projects/open-source/glfw/cmake-build-debug/examples && $(CMAKE_COMMAND) -E cmake_link_script CMakeFiles/wave.dir/link.txt --verbose=$(VERBOSE)
I manually open the file glfw/cmake-build-debug/examples/CMakeFiles/wave.dir/link.txt file and see the following link script code there:
/Library/Developer/CommandLineTools/usr/bin/cc -g -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX12.1.sdk -Wl,-search_paths_first -Wl,-headerpad_max_install_names CMakeFiles/wave.dir/wave.c.o -o wave.app/Contents/MacOS/wave ../src/libglfw3.a -framework Cocoa -framework IOKit -framework CoreFoundation
If I manually execute this line from shell, it successfully builds my binary for arm64 architecture, as expected.
But when this link.txt script is automatically invoked with cmake via cmake -E cmake_link_script CMakeFiles/wave.dir/link.txt --verbose=$(VERBOSE), it fails, apparently, trying to build the binary for the wrong x86_64 architecture.
Why is this happening and how to fix this?
For anyone running into the same problem, it looks like the first version of cmake with an adequate support for Apple Silicon is 3.19.
I was using 3.17.5 as my slightly out-of-date version of CLion does not support versions of cmake above that.
After an update to cmake 3.22.4 the problem is gone.

a problem with the raylib installation on linux

im using Peppermint 10 an ubuntu based distro
so i did the following commands here and everything went well until this
(the input)
cmake -DBUILD_SHARED_LIBS=ON ..
(the output)
-- Testing if -Werror=pointer-arith can be used -- compiles
-- Testing if -Werror=implicit-function-declaration can be used -- compiles
-- Testing if -fno-strict-aliasing can be used -- compiles
-- Using raylib's GLFW
-- Using X11 for window creation
-- Audio Backend: miniaudio
-- Building raylib shared library
-- Generated build type: Debug
-- Compiling with the flags:
-- PLATFORM=PLATFORM_DESKTOP
-- GRAPHICS=GRAPHICS_API_OPENGL_33
-- Building examples is enabled
-- Testing if -std=c11 can be used -- compiles
-- Configuring done
CMake Error at src/CMakeLists.txt:57 (add_library):
Error evaluating generator expression:
$<TARGET_OBJECTS:glfw>
Objects of target "glfw" referenced but is not an OBJECT library.
CMake Error: CMake can not determine linker language for target: raylib
CMake Error: Cannot determine link language for target "raylib".
-- Generating done
-- Build files have been written to: /home/anas/raylib/build
how do i even fix these cmake errors?
but then i ignored these thought it was normal but when i tried to do the following command
(the command aka the input)
make
(the output)
[ 7%] Built target glfw
make[2]: *** No rule to make target 'raylib/CMakeFiles/raylib.dir/build'. Stop.
CMakeFiles/Makefile2:87: recipe for target 'raylib/CMakeFiles/raylib.dir/all' failed
make[1]: *** [raylib/CMakeFiles/raylib.dir/all] Error 2
Makefile:162: recipe for target 'all' failed
make: *** [all] Error 2
it shows the same thing when i try sudo make install
help
i still dont know what is the problem here
btw im following the wiki here
Do this:
sudo apt install g++
sudo apt install cmake (should be in version 3.11 or higher)
download to your project folder ex. 'new-game' folder those three files from https://github.com/RobLoach/raylib-cpp/tree/master/projects/CMake (main.cpp, README.md, CMakeLists.txt)
then cd new-game && mkdir build && cd build && cmake .. && make
run ./raylib-cpp-example

Building ASSIMP with MinGW causes file too big error

I am building ASSIMP using cmake and mingw-w64 on windows 10 and it gives me "file too big" errors while creating the object code. I tried using MinGW and MinGW-w64 and both give me the same error. I am using the default settings, I configure the project with cmake, generate the makefile and then run mingw32-make. Is there some kind of flag I can set to fix this?
Compiler:
g++ (x86_64-posix-seh-rev0, Built by MinGW-W64 project) 8.1.0
Here is the output:
[ 59%] Building CXX object code/CMakeFiles/assimp.dir/Importer/StepFile/StepFileImporter.cpp.obj
[ 60%] Building CXX object code/CMakeFiles/assimp.dir/Importer/StepFile/StepFileGen1.cpp.obj
C:/mingw-w64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/../../../../x86_64-w64-mingw32/bin/as.exe:
CMakeFiles\assimp.dir\Importer\StepFile\StepFileGen1.cpp.obj: section .xdata$_ZNSt10_Head_baseILy0EPN6Assimp8StepFile29directed_dimensional_locationELb0EE7_M_headERKS4_:
string table overflow at offset 10000029
C:\Users\ANDREW~1.NOT\AppData\Local\Temp\ccwwseVM.s: Assembler messages:
C:\Users\ANDREW~1.NOT\AppData\Local\Temp\ccwwseVM.s: Fatal error: can't close CMakeFiles\assimp.dir\Importer\StepFile\StepFileGen1.cpp.obj: File too big
mingw32-make[2]: *** [code\CMakeFiles\assimp.dir\build.make:2485: code/CMakeFiles/assimp.dir/Importer/StepFile/StepFileGen1.cpp.obj] Error 1
mingw32-make[1]: *** [CMakeFiles\Makefile2:274: code/CMakeFiles/assimp.dir/all] Error 2
mingw32-make: *** [Makefile:129: all] Error 2
EDIT: I was using the master branch of Assimp from github, which has newer experimental features. I downloaded an older release version and I did not get the same errors.
This error is fixed by assimp itself https://github.com/assimp/assimp/issues/2406 Which version do you use?
What worked for me :
Go into the CMakeLists.txt and add:
set(CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS} "-O3")
Then compile with some options off:
cmake .. -G "Unix Makefiles" -DASSIMP_BUILD_ASSIMP_TOOLS=OFF -DASSIMP_BUILD_TESTS=OFF
make -j4 && make install
It worked for 5.0.0-rc1 and 5.0.1 too.

Mingw32-Make & cmake 3.0

Well i am trying to compile opencv on my own for eclipsecdt4. I am following a tutorial for codeblocks over here
http://kevinhughes.ca/tutorials/opencv-install-on-windows-with-codeblocks-and-mingw/
I did the cmake thing with eclipse cdt4-mingw32makefile config(tried with just mingw32 makefile too) but the makefile isnt generating. When i do mingw32-make in the build directory it says
F:\ocv\build>mingw32-make
mingw32-make: *** No targets specified and no makefile found. Stop.
Here is a screenshot of the build directory
I had excatly the same problem....I solved it today...I forgot to press Generate in Cmake.....

Compile cling bug

I'm trying to compile Cling (followed build instructions) and i'm unable to find bug reports maillist:
llvm[4]: Compiling AutoSynthesizer.cpp for Debug+Asserts build
llvm[4]: Compiling AutoloadCallback.cpp for Debug+Asserts build
/Users/asmirnov/Documents/dev/src/llvm_cling/tools/cling/lib/Interpreter/AutoloadCallback.cpp:16:67: error:
expected a class or namespace
= sema.getDiagnostics().getCustomDiagID (DiagnosticsEngine::Level::Warning,
~~~~~~~~~~~~~~~~~~~^
1 error generated.
make[4]: *** [/Users/asmirnov/Documents/dev/src/llvm_cling_build/tools/cling/lib/Interpreter/Debug+Asserts/AutoloadCallback.o] Error 1
Use -enable-cxx11 configure option. Updated build tutorial after it.