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]: comgr fails to build hip code on musl systems #92

Closed
AngryLoki opened this issue May 22, 2024 · 3 comments
Closed

[Issue]: comgr fails to build hip code on musl systems #92

AngryLoki opened this issue May 22, 2024 · 3 comments
Assignees
Labels
comgr Related to Code Object Manager

Comments

@AngryLoki
Copy link

Problem Description

While running amd/comgr autotests with musl libc, tests related to HIP code fail like this:

33/38 Test: comgr_compile_source_to_executable
Command: "/var/tmp/portage/dev-libs/rocm-comgr-6.1.1/work/llvm-project-rocm-6.1.1/amd/comgr_build/test/compile_source_to_executable"
Directory: /var/tmp/portage/dev-libs/rocm-comgr-6.1.1/work/llvm-project-rocm-6.1.1/amd/comgr_build/test
"comgr_compile_source_to_executable" start time: May 22 04:02 UTC
Output:
----------------------------------------------------------
In file included from <built-in>:1:
In file included from /usr/lib/llvm/18/bin/../../../../lib/clang/18/include/__clang_hip_runtime_wrapper.h:111:
/usr/lib/llvm/18/bin/../../../../lib/clang/18/include/cuda_wrappers/cmath:27:15: fatal error: 'cmath' file not found
   27 | #include_next <cmath>
      |               ^~~~~~~
1 error generated when compiling for gfx900.
FAILED: amd_comgr_do_action
 REASON: ERROR
<end of output>
Test time =   0.74 sec
----------------------------------------------------------
Test Failed.

Note, that clang and hipcc work, this is just an issue of comgr runtime compiler.

The problem is caused by lines https://github.com/ROCm/llvm-project/blob/rocm-6.1.1/amd/comgr/src/comgr-compiler.cpp#L1054-L1055

    Args.push_back("-target");
    Args.push_back("x86_64-unknown-linux-gnu");

The correct target would be x86_64-unknown-linux-musl, however the easiest fix is just to remove these 2 lines, because clang uses host target by default. Removing these 2 lines allows all comgr tests to pass with musl libc (given that other non-musl fixes are applied and excluding comgr_nested_kernel_test due to #35).

Not setting -target enables automatic target selection and setting up flags:

  • glibc system automatically adds /usr/lib/gcc/x86_64-pc-linux-gnu/13/include/g++-v13/ to include path
  • musl system automatically adds /usr/lib/gcc/x86_64-gentoo-linux-musl/13/include/g++-v13/ to include path

Operating System

Gentoo / musl profile

CPU

GPU

AMD Instinct MI300X

ROCm Version

ROCm 6.1.0

ROCm Component

No response

Steps to Reproduce

No response

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

No response

Additional Information

No response

@lamb-j lamb-j self-assigned this May 22, 2024
@lamb-j lamb-j added the comgr Related to Code Object Manager label May 22, 2024
@lamb-j
Copy link
Collaborator

lamb-j commented May 22, 2024

Thanks for the suggestion!

Testing your suggested change internally, I'll report back with the results

@lamb-j
Copy link
Collaborator

lamb-j commented Jun 6, 2024

Still testing the change removing these lines:

Args.push_back("-target");
Args.push_back("x86_64-unknown-linux-gnu");

Initial tests removing those have broken some components relying on Comgr, like hipRTC. I'm looking into those failures now

searlmc1 pushed a commit that referenced this issue Jun 11, 2024
Reported here: #92

Instead of hardcoding the -target option, allow clang to use
the default target. This avoids issues when using musl, which
requires a 'x86_64-unknown-linux-musl' target.

Change-Id: I6a24dda4078f914e47bf3b4b2715dbce9d1a513f
@lamb-j
Copy link
Collaborator

lamb-j commented Jun 11, 2024

9f0d168

Let me know if this doesn't fix your issue. Thanks again for the suggestion!

@lamb-j lamb-j closed this as completed Jun 11, 2024
searlmc1 pushed a commit that referenced this issue Jun 28, 2024
Reported here: #92

Instead of hardcoding the -target option, allow clang to use
the default target. This avoids issues when using musl, which
requires a 'x86_64-unknown-linux-musl' target.

Change-Id: I6a24dda4078f914e47bf3b4b2715dbce9d1a513f
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
comgr Related to Code Object Manager
Projects
None yet
Development

No branches or pull requests

2 participants