Skip to content

Commit e8e7c92

Browse files
committed
Makefile: filter chipStar clang-only flags from HIPCONFIG_CPPFLAGS for gcc
chipStar's hipconfig -C outputs --offload=spirv64, -nohipwrapperinc, --hip-path=, and --target= which are clang-only flags. When CC=gcc is used for .c files (or CXX != HIPCC for .cpp files), these flags cause build failures. Add HIPCONFIG_CPPFLAGS_C that filters the clang-only flags and adds an explicit -I$(ROCM_DIR)/include (since -nohipwrapperinc was suppressing the wrapper that would have pulled in hip_runtime.h).
1 parent 2b8414e commit e8e7c92

1 file changed

Lines changed: 9 additions & 2 deletions

File tree

Makefile

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -581,9 +581,16 @@ HIP_LIB_DIR := $(patsubst %/,%,$(dir $(firstword $(HIP_LIB_DIR))))
581581
HIP_BACKENDS = /gpu/hip/ref /gpu/hip/shared /gpu/hip/gen
582582
ifneq ($(HIP_LIB_DIR),)
583583
HIPCONFIG_CPPFLAGS := $(shell $(ROCM_DIR)/bin/hipconfig -C)
584-
$(hip-all.c:%.c=$(OBJDIR)/%.o) $(hip-all.c:%=%.tidy): CPPFLAGS += $(HIPCONFIG_CPPFLAGS)
584+
# chipStar hipconfig -C includes clang-only flags (--target=, --offload=, -nohipwrapperinc, --hip-path=);
585+
# strip those out for gcc-compiled C sources, keeping -D/-I/-include flags
586+
ifeq ($(HIP_LIB_NAME),CHIP)
587+
HIPCONFIG_CPPFLAGS_C := $(filter-out --offload% -nohipwrapperinc --hip-path% --target%,$(HIPCONFIG_CPPFLAGS)) -I$(ROCM_DIR)/include
588+
else
589+
HIPCONFIG_CPPFLAGS_C := $(HIPCONFIG_CPPFLAGS)
590+
endif
591+
$(hip-all.c:%.c=$(OBJDIR)/%.o) $(hip-all.c:%=%.tidy): CPPFLAGS += $(HIPCONFIG_CPPFLAGS_C)
585592
ifneq ($(CXX), $(HIPCC))
586-
$(hip-all.cpp:%.cpp=$(OBJDIR)/%.o) $(hip-all.cpp:%=%.tidy): CPPFLAGS += $(HIPCONFIG_CPPFLAGS)
593+
$(hip-all.cpp:%.cpp=$(OBJDIR)/%.o) $(hip-all.cpp:%=%.tidy): CPPFLAGS += $(HIPCONFIG_CPPFLAGS_C)
587594
endif
588595
PKG_LIBS += -L$(abspath $(HIP_LIB_DIR)) -l${HIP_LIB_NAME} -lhipblas
589596
LIBCEED_CONTAINS_CXX = 1

0 commit comments

Comments
 (0)