[Mesa-dev] [PATCH] radeonsi: Fix build on LLVM < 3.9

Tom Stellard thomas.stellard at amd.com
Tue Jan 31 21:45:11 UTC 2017


This was broken by: e0cc0a614c96011958bc3a1b84da9168e0e1ccbb
---
 src/gallium/drivers/radeonsi/si_shader_tgsi_setup.c | 14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)

diff --git a/src/gallium/drivers/radeonsi/si_shader_tgsi_setup.c b/src/gallium/drivers/radeonsi/si_shader_tgsi_setup.c
index 205686a..897faae 100644
--- a/src/gallium/drivers/radeonsi/si_shader_tgsi_setup.c
+++ b/src/gallium/drivers/radeonsi/si_shader_tgsi_setup.c
@@ -1257,7 +1257,11 @@ void si_llvm_context_init(struct si_shader_context *ctx,
 {
 	struct lp_type type;
 	LLVMTargetDataRef data_layout = LLVMCreateTargetDataLayout(tm);
-	char *data_layout_str = LLVMCopyStringRepOfTargetData(data_layout);
+	char *data_layout_str = NULL;
+
+	if (HAVE_LLVM >= 0x0309) {
+		data_layout_str = LLVMCopyStringRepOfTargetData(data_layout);
+	}
 
 	/* Initialize the gallivm object:
 	 * We are only using the module, context, and builder fields of this struct.
@@ -1275,9 +1279,11 @@ void si_llvm_context_init(struct si_shader_context *ctx,
 						ctx->gallivm.context);
 	LLVMSetTarget(ctx->gallivm.module, "amdgcn--");
 
-	LLVMSetDataLayout(ctx->gallivm.module, data_layout_str);
-	LLVMDisposeTargetData(data_layout);
-	LLVMDisposeMessage(data_layout_str);
+	if (data_layout_str) {
+		LLVMSetDataLayout(ctx->gallivm.module, data_layout_str);
+		LLVMDisposeTargetData(data_layout);
+		LLVMDisposeMessage(data_layout_str);
+	}
 
 	bool unsafe_fpmath = (sscreen->b.debug_flags & DBG_UNSAFE_MATH) != 0;
 	ctx->gallivm.builder = lp_create_builder(ctx->gallivm.context,
-- 
2.7.4



More information about the mesa-dev mailing list