android: radeon: fix LLVMInitializeAMDGPU* functions declaration
authorMauro Rossi <issor.oruam@gmail.com>
Tue, 10 Jan 2017 00:53:00 +0000 (01:53 +0100)
committerEmil Velikov <emil.l.velikov@gmail.com>
Wed, 18 Jan 2017 16:21:28 +0000 (16:21 +0000)
LLVMInitializeAMDGPU* functions need to be explicitly declared
and mesa expects them via <llvm-c/Target.h> header,
but LLVM needs to be instructed to invoke its own LLVM_TARGET(AMDGPU) macro,
or the functions will not be available.

A new llvm cflag (-DFORCE_BUILD_AMDGPU) serves this purpose,
the same mechanism is used also by other llvm targets e.g. FORCE_BUILD_ARM

A necessary prerequisite is to have AMDGPU target handled accordingly
in llvm config files i.e. {Target,AsmParser,AsmPrinter}.def
for llvm device build includes.

This avoids the following building errors:

external/mesa/src/gallium/drivers/radeon/radeon_llvm_emit.c:121:2: error: implicit declaration of function 'LLVMInitializeAMDGPUTargetInfo' [-Werror=implicit-function-declaration]
  LLVMInitializeAMDGPUTargetInfo();
  ^
external/mesa/src/gallium/drivers/radeon/radeon_llvm_emit.c:122:2: error: implicit declaration of function 'LLVMInitializeAMDGPUTarget' [-Werror=implicit-function-declaration]
  LLVMInitializeAMDGPUTarget();
  ^
external/mesa/src/gallium/drivers/radeon/radeon_llvm_emit.c:123:2: error: implicit declaration of function 'LLVMInitializeAMDGPUTargetMC' [-Werror=implicit-function-declaration]
  LLVMInitializeAMDGPUTargetMC();
  ^
external/mesa/src/gallium/drivers/radeon/radeon_llvm_emit.c:124:2: error: implicit declaration of function 'LLVMInitializeAMDGPUAsmPrinter' [-Werror=implicit-function-declaration]
  LLVMInitializeAMDGPUAsmPrinter();
  ^

Acked-by: Nicolai Hähnle <nicolai.haehnle@amd.com>
Acked-by: Emil Velikov <emil.velikov@collabora.com>
src/gallium/drivers/radeon/Android.mk

index 2f72f1f5639a203b691b9c89d78863aae097f1c1..31eaa16e9417a59fbb0c49d0c3e0133b0694a175 100644 (file)
@@ -32,6 +32,7 @@ LOCAL_SRC_FILES := $(C_SOURCES)
 
 ifeq ($(MESA_ENABLE_LLVM),true)
 LOCAL_SRC_FILES += $(LLVM_C_FILES)
+LOCAL_CFLAGS += -DFORCE_BUILD_AMDGPU   # instructs LLVM to declare LLVMInitializeAMDGPU* functions
 endif
 
 LOCAL_SHARED_LIBRARIES := libdrm_radeon