[libclc] [libclc] Pass -fapprox-func when compiling 'native' builtins (PR #133119)
Fraser Cormack via cfe-commits
cfe-commits at lists.llvm.org
Wed Mar 26 09:36:38 PDT 2025
https://github.com/frasercrmck created https://github.com/llvm/llvm-project/pull/133119
The libclc build system isn't well set up to pass arbitrary options to arbitrary source files in a non-intrusive way. There isn't currently any other motivating example to warrant rewriting the build system just to satisfy this requirement. So this commit uses a filename-based approach to inserting this option into the list of compile flags.
>From 7bea9635d1f92a376f203255880ac91118697d3a Mon Sep 17 00:00:00 2001
From: Fraser Cormack <fraser at codeplay.com>
Date: Wed, 26 Mar 2025 16:18:34 +0000
Subject: [PATCH] [libclc] Pass -fapprox-func when compiling 'native' builtins
The libclc build system isn't well set up to pass arbitrary options to
arbitrary source files in a non-intrusive way. There isn't currently any
other motivating example to warrant rewriting the build system just to
satisfy this requirement. So this commit uses a filename-based approach
to inserting this option into the list of compile flags.
---
libclc/cmake/modules/AddLibclc.cmake | 11 ++++++++++-
1 file changed, 10 insertions(+), 1 deletion(-)
diff --git a/libclc/cmake/modules/AddLibclc.cmake b/libclc/cmake/modules/AddLibclc.cmake
index be8937cd13107..0bc93eb4cf091 100644
--- a/libclc/cmake/modules/AddLibclc.cmake
+++ b/libclc/cmake/modules/AddLibclc.cmake
@@ -260,12 +260,21 @@ function(add_libclc_builtin_set)
endif()
get_filename_component( file_dir ${file} DIRECTORY )
+ get_filename_component( input_filename ${file} NAME_WE )
+
+ # If this is a 'native' function (as judged by its filename beginning with
+ # "(clc_)?native_") then pass extra args.
+ set( native_flag )
+ string( REGEX MATCH "^(clc_)?native_" is_native "${input_filename}" )
+ if( NOT "${is_native}" STREQUAL "" )
+ set( native_flag -fapprox-func )
+ endif()
compile_to_bc(
TRIPLE ${ARG_TRIPLE}
INPUT ${input_file}
OUTPUT ${output_file}
- EXTRA_OPTS -fno-builtin -nostdlib
+ EXTRA_OPTS -fno-builtin -nostdlib ${native_flag}
"${ARG_COMPILE_FLAGS}" -I${CMAKE_CURRENT_SOURCE_DIR}/${file_dir}
DEPENDENCIES ${input_file_dep}
)
More information about the cfe-commits
mailing list