fix(libhsakmt): Define _GNU_SOURCE before libhsakmt.h include#8555
Conversation
_GNU_SOURCE must be defined before any system header is pulled in; libhsakmt.h includes pthread.h and other libc headers, so defining it after that include breaks GNU extension visibility in some build envs. Co-authored-by: Cursor <cursoragent@cursor.com>
hsakmtmodel.h and hsakmt_drm.h pull in amdgpu/drm headers before libhsakmt.h, so _GNU_SOURCE must be the first definition in the TU. Co-authored-by: Cursor <cursoragent@cursor.com>
Test results (dayatsin-test-01)Host: Ubuntu 24.04.3 LTS, amdclang 23.0.0 (
Note: the initial commit only moved |
❌ PR Check — Action Required
📖 Need help? See the Policy FAQ for details on every check and how to fix failures. |
|
🚫 Please fix the failed policies before requesting reviews. The following policy checks failed:
The |
_GNU_SOURCE at the top of the TU already enables the same glibc extensions; __USE_GNU is redundant and can conflict in strict builds. Co-authored-by: Cursor <cursoragent@cursor.com>
Re-test after removing
|
| Test | Result |
|---|---|
| ASAN full rocr-runtime build | PASS |
Release hsakmt build |
PASS |
hsakmtmodel.c compile errors |
None |
_GNU_SOURCE alone is sufficient; __USE_GNU is redundant with it defined at the top of the TU.
Summary
Move
#define _GNU_SOURCEto the top ofhsakmtmodel.c, before all includes, and remove the redundant#define __USE_GNU._GNU_SOURCEmust be defined before any system header is pulled in;hsakmtmodel.h,hsakmt_drm.h, andlibhsakmt.hall transitively include libc/drm headers. Defining it after those includes breaks GNU extension visibility (e.g.secure_getenv) and causes compile errors in strict or sanitizer builds.JIRA ID
JIRA ID : ROCM-26861
Test plan
Tested on dayatsin-test-01 (Ubuntu 24.04, amdclang 23.0.0 from
/opt/rocm), including after removing__USE_GNU(c651d3f278):libhsakmt/rocr-runtimewith ASAN enabled (-DADDRESS_SANITIZER=ON -DTHEROCK_SANITIZER=ASAN) — full build succeeded (libhsa-runtime64.soproduced)hsakmttarget succeededhsakmtmodel.ccompiles without_GNU_SOURCEordering warnings/errors — no errors in either ASAN or Release builds