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

[Issue]: ld.lld: error: undefined symbol: __cxa_allocate_exception #3733

Closed
RandUser123sa opened this issue Dec 27, 2024 · 9 comments
Closed

Comments

@RandUser123sa
Copy link

Problem Description

I'm trying to compile AMDMIGraphX-rocm-6.3.1 release version and I receive a compilation errors attached.

compileerr.txt

Operating System

Slackware 15.0 x86_64

CPU

AMD Ryzen 7 3800X 8-Core Processor

GPU

AMD Radeon RX 7900 XTX

Other

No response

ROCm Version

ROCm 6.0.0

Steps to Reproduce

Here is my configuration parameters:

CXX=/opt/rocm/llvm/bin/clang++ cmake -B build
-D CMAKE_CXX_COMPILER=/opt/rocm/llvm/bin/amdclang
-D CMAKE_C_COMPILER=/opt/rocm/llvm/bin/amdclang
-D CMAKE_BUILD_TYPE=Release
-D CMAKE_PREFIX_PATH=/opt/rocm/lib/llvm/lib/cmake
-D ROCM_GDB="/opt/rocm/bin/rocdbg"
-D HALF_INCLUDE_DIR="/opt/rocm/include"
-D MIGRAPHX_ENABLE_GPU=ON
-D MIGRAPHX_USE_COMPOSABLEKERNEL=OFF
-D BUILD_TESTING=OFF
-D MIGRAPHX_ENABLE_MLIR=ON
-D MIGRAPHX_ENABLE_CPU=OFF
-D AMDGPU_TARGETS="gfx900;gfx906:xnack-;gfx908:xnack-;gfx90a;gfx942;gfx1010;gfx1012;gfx1030;gfx1100;gfx1101;gfx1102;gfx1151;gfx1200;gfx1201"
-D GPU_TARGETS="gfx900;gfx906:xnack-;gfx908:xnack-;gfx90a;gfx942;gfx1010;gfx1012;gfx1030;gfx1100;gfx1101;gfx1102;gfx1151;gfx1200;gfx1201"

and I also increase the ulimits to ulimit -n 4096

(Optional for Linux users) Output of /opt/rocm/bin/rocminfo --support

ROCk module is loaded

HSA System Attributes

Runtime Version: 1.14
Runtime Ext Version: 1.6
System Timestamp Freq.: 1000.000000MHz
Sig. Max Wait Duration: 18446744073709551615 (0xFFFFFFFFFFFFFFFF) (timestamp count)
Machine Model: LARGE
System Endianness: LITTLE
Mwaitx: DISABLED
DMAbuf Support: YES

==========
HSA Agents


Agent 1


Name: AMD Ryzen 7 3800X 8-Core Processor
Uuid: CPU-XX
Marketing Name: AMD Ryzen 7 3800X 8-Core Processor
Vendor Name: CPU
Feature: None specified
Profile: FULL_PROFILE
Float Round Mode: NEAR
Max Queue Number: 0(0x0)
Queue Min Size: 0(0x0)
Queue Max Size: 0(0x0)
Queue Type: MULTI
Node: 0
Device Type: CPU
Cache Info:
L1: 32768(0x8000) KB
Chip ID: 0(0x0)
ASIC Revision: 0(0x0)
Cacheline Size: 64(0x40)
Max Clock Freq. (MHz): 4560
BDFID: 0
Internal Node ID: 0
Compute Unit: 16
SIMDs per CU: 0
Shader Engines: 0
Shader Arrs. per Eng.: 0
WatchPts on Addr. Ranges:1
Memory Properties:
Features: None
Pool Info:
Pool 1
Segment: GLOBAL; FLAGS: FINE GRAINED
Size: 32787692(0x1f44cec) KB
Allocatable: TRUE
Alloc Granule: 4KB
Alloc Recommended Granule:4KB
Alloc Alignment: 4KB
Accessible by all: TRUE
Pool 2
Segment: GLOBAL; FLAGS: EXTENDED FINE GRAINED
Size: 32787692(0x1f44cec) KB
Allocatable: TRUE
Alloc Granule: 4KB
Alloc Recommended Granule:4KB
Alloc Alignment: 4KB
Accessible by all: TRUE
Pool 3
Segment: GLOBAL; FLAGS: KERNARG, FINE GRAINED
Size: 32787692(0x1f44cec) KB
Allocatable: TRUE
Alloc Granule: 4KB
Alloc Recommended Granule:4KB
Alloc Alignment: 4KB
Accessible by all: TRUE
Pool 4
Segment: GLOBAL; FLAGS: COARSE GRAINED
Size: 32787692(0x1f44cec) KB
Allocatable: TRUE
Alloc Granule: 4KB
Alloc Recommended Granule:4KB
Alloc Alignment: 4KB
Accessible by all: TRUE
ISA Info:


Agent 2


Name: gfx1100
Uuid: GPU-6e99eccb20090e4e
Marketing Name: AMD Radeon RX 7900 XTX
Vendor Name: AMD
Feature: KERNEL_DISPATCH
Profile: BASE_PROFILE
Float Round Mode: NEAR
Max Queue Number: 128(0x80)
Queue Min Size: 64(0x40)
Queue Max Size: 131072(0x20000)
Queue Type: MULTI
Node: 1
Device Type: GPU
Cache Info:
L1: 32(0x20) KB
L2: 6144(0x1800) KB
L3: 98304(0x18000) KB
Chip ID: 29772(0x744c)
ASIC Revision: 0(0x0)
Cacheline Size: 128(0x80)
Max Clock Freq. (MHz): 2482
BDFID: 3072
Internal Node ID: 1
Compute Unit: 96
SIMDs per CU: 2
Shader Engines: 6
Shader Arrs. per Eng.: 2
WatchPts on Addr. Ranges:4
Coherent Host Access: FALSE
Memory Properties:
Features: KERNEL_DISPATCH
Fast F16 Operation: TRUE
Wavefront Size: 32(0x20)
Workgroup Max Size: 1024(0x400)
Workgroup Max Size per Dimension:
x 1024(0x400)
y 1024(0x400)
z 1024(0x400)
Max Waves Per CU: 32(0x20)
Max Work-item Per CU: 1024(0x400)
Grid Max Size: 4294967295(0xffffffff)
Grid Max Size per Dimension:
x 4294967295(0xffffffff)
y 4294967295(0xffffffff)
z 4294967295(0xffffffff)
Max fbarriers/Workgrp: 32
Packet Processor uCode:: 462
SDMA engine uCode:: 24
IOMMU Support:: None
Pool Info:
Pool 1
Segment: GLOBAL; FLAGS: COARSE GRAINED
Size: 25149440(0x17fc000) KB
Allocatable: TRUE
Alloc Granule: 4KB
Alloc Recommended Granule:2048KB
Alloc Alignment: 4KB
Accessible by all: FALSE
Pool 2
Segment: GLOBAL; FLAGS: EXTENDED FINE GRAINED
Size: 25149440(0x17fc000) KB
Allocatable: TRUE
Alloc Granule: 4KB
Alloc Recommended Granule:2048KB
Alloc Alignment: 4KB
Accessible by all: FALSE
Pool 3
Segment: GROUP
Size: 64(0x40) KB
Allocatable: FALSE
Alloc Granule: 0KB
Alloc Recommended Granule:0KB
Alloc Alignment: 0KB
Accessible by all: FALSE
ISA Info:
ISA 1
Name: amdgcn-amd-amdhsa--gfx1100
Machine Models: HSA_MACHINE_MODEL_LARGE
Profiles: HSA_PROFILE_BASE
Default Rounding Mode: NEAR
Default Rounding Mode: NEAR
Fast f16: TRUE
Workgroup Max Size: 1024(0x400)
Workgroup Max Size per Dimension:
x 1024(0x400)
y 1024(0x400)
z 1024(0x400)
Grid Max Size: 4294967295(0xffffffff)
Grid Max Size per Dimension:
x 4294967295(0xffffffff)
y 4294967295(0xffffffff)
z 4294967295(0xffffffff)
FBarrier Max Size: 32
*** Done ***

Additional Information

OS:
NAME=Slackware
VERSION="15.0"
CPU:
model name : AMD Ryzen 7 3800X 8-Core Processor
GPU:
Name: AMD Ryzen 7 3800X 8-Core Processor
Marketing Name: AMD Ryzen 7 3800X 8-Core Processor
Name: gfx1100
Marketing Name: AMD Radeon RX 7900 XTX
Name: amdgcn-amd-amdhsa--gfx1100

Configure log
config.txt

@ppanchad-amd
Copy link

Hi @RandUser123sa. Internal ticket has been created to investigate your issue. Thanks!

@taylding-amd
Copy link
Contributor

Hi @RandUser123sa,

I recently attempted to build AMDMIGraphX-rocm-6.3.1 and did not encounter the error you mentioned. Given that AMDMIGraphX has numerous dependencies, building from source can sometimes lead to environmental issues.

I recommend using Docker, as it provides the easiest way to set up the development environment. If you prefer not to use Docker, you can still refer to our Dockerfile for environment reference.

Here’s a quick guide on how to use Docker:

  1. Build a Docker image using the Dockerfile:
    docker build -t migraphx .
  2. Enter the development environment with the following command:
    docker run --device='/dev/kfd' --device='/dev/dri' -v=`pwd`:/code/AMDMIGraphX -w /code/AMDMIGraphX --group-add video -it migraphx
  3. Inside the Docker container, all required prerequisites are already installed. You can navigate to the /code/AMDMIGraphX folder and follow the steps (starting from step 2) in the Use CMake to build MIGraphX guide.

@RandUser123sa
Copy link
Author

RandUser123sa commented Jan 4, 2025

Hi @taylding-amd

I have all the packages described from your Docker file. I don't have debian to check, but on docker file the clang required version 14, my is clang version 19.

clang version 19.1.6 Target: x86_64-unknown-linux-gnu Thread model: posix InstalledDir: /usr/bin Found candidate GCC installation: /usr/bin/../lib/gcc/x86_64-slackware-linux/14.2.0 Found candidate GCC installation: /usr/bin/../lib64/gcc/x86_64-slackware-linux/14.2.0 Selected GCC installation: /usr/bin/../lib64/gcc/x86_64-slackware-linux/14.2.0 Candidate multilib: .;@m64 Candidate multilib: 32;@m32 Selected multilib: .;@m64 Found HIP installation: /opt/rocm, version 6.3.42133

The last version that I was able to compile in past was AMDMIGraphX 6.1.0.

I think this error is happened because the library libstdc++ was not added into the linker command line. I know this is not your problem but could please help me just a little bit because my knowledge about cmake isn't much to tell me how to add -lstdc++ into the file which execute this step:

`
[ 97%] Linking CXX executable ../../../../bin/migraphx-hiprtc-driver
ld.lld: error: undefined symbol: __cxa_allocate_exception

referenced by main.cpp
CMakeFiles/migraphx-hiprtc-driver.dir/main.cpp.o:(read_stdin())
referenced by main.cpp
CMakeFiles/migraphx-hiprtc-driver.dir/main.cpp.o:(void migraphx::version_2_11_0::value::visit<std::__cxx11::basic_string<char, std::char_traits, std::allocator> migraphx::version_2_11_0::value::to<std::__cxx11::basic_string<char, std::char_traits, std::allocator>>() const::'lambda'(std::__cxx11::basic_string<char, std::char_traits, std::allocator>)>(std::__cxx11::basic_string<char, std::char_traits, std::allocator>) const)
referenced by main.cpp
......
make[2]: *** [src/targets/gpu/hiprtc/CMakeFiles/migraphx-hiprtc-driver.dir/build.make:109: bin/migraphx-hiprtc-driver] Error 1
make[1]: *** [CMakeFiles/Makefile2:1079: src/targets/gpu/hiprtc/CMakeFiles/migraphx-hiprtc-driver.dir/all] Error 2
make[1]: *** Waiting for unfinished jobs....
[ 97%] Linking CXX executable ../../../../bin/gpu-driver
ld.lld: error: undefined symbol: operator new(unsigned long)
referenced by main.cpp
CMakeFiles/gpu-driver.dir/main.cpp.o:(main)
referenced by parser.cpp
CMakeFiles/gpu-driver.dir/parser.cpp.o:(migraphx::version_2_11_0::gpu::driver::parser::parse_shape(migraphx::version_2_11_0::value const&) const)
referenced by parser.cpp
CMakeFiles/gpu-driver.dir/parser.cpp.o:(migraphx::version_2_11_0::gpu::driver::parser::parse_shape(migraphx::version_2_11_0::value const&) const)
referenced 26 more times

`

I can't use docker container, but BTW I can disable clang-tidy with: -D ROCM_ENABLE_CLANG_TIDY=OFF
and the crash it's not happened.

@pfultz2
Copy link
Collaborator

pfultz2 commented Jan 4, 2025

CMake supports the simliar env variables from autoconf so you can set the env variable LDFLAGS=-lstdc++ when you configure cmake the first time so it adds the linker flag.

@RandUser123sa
Copy link
Author

RandUser123sa commented Jan 5, 2025

Hi @pfultz2

It's seems this is work, I also change the build params. I replace the first line from my build script from:
CXX=/opt/rocm/llvm/bin/clang++ cmake -B build
to
cmake -B build

and now error make sense:

[ 97%] Linking CXX executable ../../../../bin/migraphx-hiprtc-driver
ld.lld: error: undefined reference due to --no-allow-shlib-undefined: log2

referenced by /opt/rocm/lib/libhipblaslt.so.0.10.60301

newerror.txt

I think this --no-allow-shlib-undefined option tells the linker not to allow .so libraries to be created in which not all of the symbols are defined up front.

@RandUser123sa
Copy link
Author

RandUser123sa commented Jan 6, 2025

I was able to compile the project on Slackware 64. For my conclusion this is happened because probably the AMDMIGraphX on debian is compiled with llvm-14, my version is 18. Also I added LDFLAGS=-lstdc++ to environment and change default behavior of cmake with adding param -allow-shlib-undefined to link.txt into following directories:

build/src/driver/CMakeFiles/driver.dir
build/src/targets/gpu/driver/CMakeFiles/gpu-driver.dir
build/src/targets/gpu/hiprtc/CMakeFiles/migraphx-hiprtc-driver.dir

the line that I change from:
-Wl,-rpath-link,/mnt/build/rocm/rocm-build/build/amdmigraphx/lib
to:
-Wl,-allow-shlib-undefined,-rpath-link,/mnt/build/rocm/rocm-build/build/amdmigraphx/lib

Some one could tell me please how I can add this param -allow-shlib-undefined to configurator ?

@taylding-amd
Copy link
Contributor

Hi @RandUser123sa, to add the -allow-shlib-undefined parameter to the configurator in CMake, you can add the following line to your CMakeLists.txt file:
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,-allow-shlib-undefined")
I would also like to recommend another tool called ccmake. It allows you to easily modify configurations. To install it, you can use the following command:
apt install cmake-curses-gui

Additionally, I wanted to mention that while I see you are using Slackware 64, it's important to note that ROCm does not officially support this operating system (Compatibility matrix - ROCm). As a result, we do not conduct testing or provide support for ROCm on Slackware. While it’s possible that things may work, you might encounter some unexpected environmental issues.

Thank you for your understanding, and please feel free to reach out if you have any further questions!

@RandUser123sa
Copy link
Author

Hi @taylding-amd,

I know my OS it's not supported but I don't want to change my favorite OS just because one package it's not compiled. I compiled most of the ROCm packages and some times developers help me when I get some errors.

Thank you

The above method it's not working, I also try this method:


------------------------------- ROCMChecks WARNING --------------------------
Options and properties should be set on a cmake target where possible. The
variable 'CMAKE_SHARED_LINKER_FLAGS' may be set by the cmake toolchain, either by
calling 'cmake -DCMAKE_SHARED_LINKER_FLAGS="-lstdc++ -Wl,-allow-shlib-undefined"'
or set in a toolchain file and added with
'cmake -DCMAKE_TOOLCHAIN_FILE='. ROCMChecks now calling:
CMake Warning at /opt/rocm/share/rocmcmakebuildtools/cmake/ROCMChecks.cmake:46 (message):
'CMAKE_SHARED_LINKER_FLAGS' is set at
/mnt/build/rocm/release/AMDMIGraphX-rocm-6.3.1/CMakeLists.txt:<line#> shown
below:
Call Stack (most recent call first):
CMakeLists.txt:9223372036854775807 (rocm_check_toolchain_var)
CMakeLists.txt:386 (set)

-----------------------------------------------------------------------------


but not working. I checking the link.txt but it's not changed after delete the build folder and create it again.
Currently I change these 3 files with sed but I want to find another way, not with brute force. If you have some other suggestion is welcome.

The issue is resolved and you can close it any time.

@taylding-amd
Copy link
Contributor

Hi @RandUser123sa, you can also use our Azure external CI pipeline as a reference for the environment. I will be closing this issue now. Thank you!

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

No branches or pull requests

4 participants