Comhaid
rocm-systems/samples/2_Cookbook/15_static_library/host_functions/Makefile
T
Aaron En Ye Shi cfcf04d502 SWDEV-222423 - Add HIP Sample 2_Cookbook/15_static_library
HIP supports emitting two types of static libraries. One type
will export host functions and is compatible with host linkers.
The second type exports device functions, but is generated with
ar manually. Also, add a README with steps on how to run these
samples with Makefile or CMake.

Change-Id: I1be15c2884583b370092bc8e4bf04f726f8f5a27
2021-04-27 16:05:15 -04:00

39 línte
998 B
Makefile

HIP_PATH?= $(wildcard /opt/rocm/hip)
ifeq (,$(HIP_PATH))
HIP_PATH=../../..
endif
HIPCC=$(HIP_PATH)/bin/hipcc
GXX=g++
EMIT_STATIC_LIB_SRC=hipOptLibrary.cpp
EMIT_STATIC_LIB=./libHipOptLibrary.a
EMIT_STATIC_MAIN_SRC=hipMain1.cpp
HIPCC_EXE=./test_emit_static_hipcc_linker.out
HOST_EXE=./test_emit_static_host_linker.out
.PHONY: test
all: $(HIPCC_EXE) $(HOST_EXE) test
$(EMIT_STATIC_LIB):
$(HIPCC) $(EMIT_STATIC_LIB_SRC) --emit-static-lib -fPIC -o $@
# Compiles hipMain1 with hipcc and links with libHipOptLibrary.a which contains host function.
$(HIPCC_EXE): $(EMIT_STATIC_LIB)
$(HIPCC) $(EMIT_STATIC_MAIN_SRC) -L. -lHipOptLibrary -o $@
# Compiles hipMain1 with g++ and links with libHipOptLibrary.a which contains host function.
$(HOST_EXE): $(EMIT_STATIC_LIB)
$(GXX) $(EMIT_STATIC_MAIN_SRC) -L. -lHipOptLibrary -L$(HIP_PATH)/lib -lamdhip64 -o $@
test: $(HIPCC_EXE) $(HOST_EXE)
$(HIPCC_EXE)
$(HOST_EXE)
clean:
rm -f $(HIPCC_EXE)
rm -f $(HOST_EXE)
rm -f $(EMIT_STATIC_LIB)
rm -f *.o