Skip to content

Commit b20a385

Browse files
committed
[libc] Do not run tests on vendor implemented math
We currently remap vendor implementations of math functions to provide a temporarily functional `libm.a` for the GPU. However, we should not run tests on any files that depend on these vendor implementations as they are not under our control and are not always present. The goal in the future is to remove the need for this by replacing all the vendor functionality, but for now this is a workaround. Reviewed By: JonChesterfield Differential Revision: https://reviews.llvm.org/D158213
1 parent 846fbb0 commit b20a385

File tree

6 files changed

+24
-7
lines changed

6 files changed

+24
-7
lines changed

libc/cmake/modules/LLVMLibCLibraryRules.cmake

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,9 @@ function(add_entrypoint_library target_name)
7575
set(all_deps "")
7676
foreach(dep IN LISTS fq_deps_list)
7777
get_target_property(dep_type ${dep} "TARGET_TYPE")
78-
if(NOT ((${dep_type} STREQUAL ${ENTRYPOINT_OBJ_TARGET_TYPE}) OR (${dep_type} STREQUAL ${ENTRYPOINT_EXT_TARGET_TYPE})))
78+
if(NOT ((${dep_type} STREQUAL ${ENTRYPOINT_OBJ_TARGET_TYPE}) OR
79+
(${dep_type} STREQUAL ${ENTRYPOINT_EXT_TARGET_TYPE}) OR
80+
(${dep_type} STREQUAL ${ENTRYPOINT_OBJ_VENDOR_TARGET_TYPE})))
7981
message(FATAL_ERROR "Dependency '${dep}' of 'add_entrypoint_collection' is "
8082
"not an 'add_entrypoint_object' or 'add_entrypoint_external' target.")
8183
endif()

libc/cmake/modules/LLVMLibCObjectRules.cmake

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -492,6 +492,7 @@ function(add_object_library target_name)
492492
endfunction(add_object_library)
493493

494494
set(ENTRYPOINT_OBJ_TARGET_TYPE "ENTRYPOINT_OBJ")
495+
set(ENTRYPOINT_OBJ_VENDOR_TARGET_TYPE "ENTRYPOINT_OBJ_VENDOR")
495496

496497
# A rule for entrypoint object targets.
497498
# Usage:
@@ -509,20 +510,28 @@ set(ENTRYPOINT_OBJ_TARGET_TYPE "ENTRYPOINT_OBJ")
509510
function(create_entrypoint_object fq_target_name)
510511
cmake_parse_arguments(
511512
"ADD_ENTRYPOINT_OBJ"
512-
"ALIAS;REDIRECTED" # Optional argument
513+
"ALIAS;REDIRECTED;VENDOR" # Optional argument
513514
"NAME;CXX_STANDARD" # Single value arguments
514515
"SRCS;HDRS;DEPENDS;COMPILE_OPTIONS;FLAGS" # Multi value arguments
515516
${ARGN}
516517
)
517518

519+
set(entrypoint_target_type ${ENTRYPOINT_OBJ_TARGET_TYPE})
520+
if(${ADD_ENTRYPOINT_OBJ_VENDOR})
521+
# TODO: We currently rely on external definitions of certain math functions
522+
# provided by GPU vendors like AMD or Nvidia. We need to mark these so we
523+
# don't end up running tests on these. In the future all of these should be
524+
# implemented and this can be removed.
525+
set(entrypoint_target_type ${ENTRYPOINT_OBJ_VENDOR_TARGET_TYPE})
526+
endif()
518527
list(FIND TARGET_ENTRYPOINT_NAME_LIST ${ADD_ENTRYPOINT_OBJ_NAME} entrypoint_name_index)
519528
if(${entrypoint_name_index} EQUAL -1)
520529
add_custom_target(${fq_target_name})
521530
set_target_properties(
522531
${fq_target_name}
523532
PROPERTIES
524533
"ENTRYPOINT_NAME" ${ADD_ENTRYPOINT_OBJ_NAME}
525-
"TARGET_TYPE" ${ENTRYPOINT_OBJ_TARGET_TYPE}
534+
"TARGET_TYPE" ${entrypoint_target_type}
526535
"OBJECT_FILE" ""
527536
"OBJECT_FILE_RAW" ""
528537
"DEPS" ""
@@ -556,7 +565,8 @@ function(create_entrypoint_object fq_target_name)
556565
endif()
557566

558567
get_target_property(obj_type ${fq_dep_name} "TARGET_TYPE")
559-
if((NOT obj_type) OR (NOT (${obj_type} STREQUAL ${ENTRYPOINT_OBJ_TARGET_TYPE})))
568+
if((NOT obj_type) OR (NOT (${obj_type} STREQUAL ${ENTRYPOINT_OBJ_TARGET_TYPE} OR
569+
${obj_type} STREQUAL ${ENTRYPOINT_OBJ_VENDOR_TARGET_TYPE})))
560570
message(FATAL_ERROR "The aliasee of an entrypoint alias should be an entrypoint.")
561571
endif()
562572

@@ -568,7 +578,7 @@ function(create_entrypoint_object fq_target_name)
568578
${fq_target_name}
569579
PROPERTIES
570580
ENTRYPOINT_NAME ${ADD_ENTRYPOINT_OBJ_NAME}
571-
TARGET_TYPE ${ENTRYPOINT_OBJ_TARGET_TYPE}
581+
TARGET_TYPE ${entrypoint_target_type}
572582
IS_ALIAS "YES"
573583
OBJECT_FILE ""
574584
OBJECT_FILE_RAW ""

libc/cmake/modules/LLVMLibCTestRules.cmake

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,10 @@ function(get_object_files_for_test result skipped_entrypoints_list)
4343
if(object_file_raw)
4444
list(APPEND object_files ${object_file_raw})
4545
endif()
46+
elseif(${dep_type} STREQUAL ${ENTRYPOINT_OBJ_VENDOR_TARGET_TYPE})
47+
# We skip tests for all externally implemented entrypoints.
48+
list(APPEND skipped_list ${dep})
49+
continue()
4650
endif()
4751

4852
get_target_property(indirect_deps ${dep} "DEPS")

libc/src/math/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ function(add_math_entrypoint_object name)
2727
ALIAS
2828
DEPENDS
2929
.${LIBC_TARGET_ARCHITECTURE}.vendor.${name}
30+
VENDOR
3031
)
3132
return()
3233
endif()

libc/src/math/gpu/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -431,4 +431,4 @@ add_math_entrypoint_gpu_object(
431431
../truncf.h
432432
COMPILE_OPTIONS
433433
-O2
434-
)
434+
)

libc/src/math/gpu/vendor/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -467,4 +467,4 @@ add_entrypoint_object(
467467
COMPILE_OPTIONS
468468
${bitcode_link_flags}
469469
-O2
470-
)
470+
)

0 commit comments

Comments
 (0)