Skip to content

Commit aa9950f

Browse files
authored
fix(libhsakmt): Define _GNU_SOURCE before libhsakmt.h include (#8555)
## Summary Move `#define _GNU_SOURCE` to the top of `hsakmtmodel.c`, before all includes, and remove the redundant `#define __USE_GNU`. `_GNU_SOURCE` must be defined before any system header is pulled in; `hsakmtmodel.h`, `hsakmt_drm.h`, and `libhsakmt.h` all 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`): - [x] Build `libhsakmt` / `rocr-runtime` with ASAN enabled (`-DADDRESS_SANITIZER=ON -DTHEROCK_SANITIZER=ASAN`) — full build succeeded (`libhsa-runtime64.so` produced) - [x] Build with amdclang from TheRock/ROCm toolchain — Release `hsakmt` target succeeded - [x] Verify `hsakmtmodel.c` compiles without `_GNU_SOURCE` ordering warnings/errors — no errors in either ASAN or Release builds
2 parents 1add9f2 + c651d3f commit aa9950f

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

projects/rocr-runtime/libhsakmt/src/hsakmtmodel.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,13 @@
2323
* DEALINGS IN THE SOFTWARE.
2424
*/
2525

26+
#define _GNU_SOURCE
27+
2628
#include "hsakmt/hsakmtmodel.h"
2729
#include "hsakmt/hsakmt_drm.h"
2830
#include "libhsakmt.h"
2931
#include "hsakmt/hsakmttypes.h"
3032
#include "hsakmt/hsakmtmodeliface.h"
31-
#define _GNU_SOURCE
32-
#define __USE_GNU
3333
#include <assert.h>
3434
#include <errno.h>
3535
#include <inttypes.h>

0 commit comments

Comments
 (0)