Skip to content

Commit afb5cf5

Browse files
committed
[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.
1 parent db98e29 commit afb5cf5

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

libclc/cmake/modules/AddLibclc.cmake

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -260,12 +260,21 @@ function(add_libclc_builtin_set)
260260
endif()
261261

262262
get_filename_component( file_dir ${file} DIRECTORY )
263+
get_filename_component( input_filename ${file} NAME_WE )
264+
265+
# If this is a 'native' function (as judged by its filename beginning with
266+
# "(clc_)?native_") then pass extra args.
267+
set( native_flag )
268+
string( REGEX MATCH "^(clc_)?native_" is_native "${input_filename}" )
269+
if( NOT "${is_native}" STREQUAL "" )
270+
set( native_flag -fapprox-func )
271+
endif()
263272

264273
compile_to_bc(
265274
TRIPLE ${ARG_TRIPLE}
266275
INPUT ${input_file}
267276
OUTPUT ${output_file}
268-
EXTRA_OPTS -fno-builtin -nostdlib
277+
EXTRA_OPTS -fno-builtin -nostdlib ${native_flag}
269278
"${ARG_COMPILE_FLAGS}" -I${CMAKE_CURRENT_SOURCE_DIR}/${file_dir}
270279
DEPENDENCIES ${input_file_dep}
271280
)

0 commit comments

Comments
 (0)