Here is a diff that 'fixes' the ldc-profgen errors (by avoiding them) for several versions of linux I have tried. Not really sure if the is the best way to do this, but I think it should work for now at least. Hopefully we can fix the ldc-profgen issue later and this won't be necessary anyways.
This diff uses the LDC_PROFGEN environment variable to avoid building on the default build (ie. the env var is not set at all). Then one can use this env var on the CI/CD to enable the ldc-profgen compilation on the ci server via export LDC_PROFGEN="ENABLE_LDC_PROFGEN=ON" or some such (not totally sure how to set things on the ci server).
diff --git a/Makefile b/Makefile
index 9a28d62067..2650f72a9a 100644
--- a/Makefile
+++ b/Makefile
@@ -100,9 +100,11 @@ html: $(BUILD_EXE)
phobos:
cd phobos && make
+BUILD_LDC_PROFGEN := $(if $(LDC_PROFGEN),-D$(LDC_PROFGEN),)
+
ldc:
mkdir -p ldc-build
- cd ldc-build && cmake ../ldc && make
+ cd ldc-build && cmake ../ldc ${BUILD_LDC_PROFGEN} && make
# Creates Exuberant Ctags tags file
tags: Makefile $(ECTAGS_FILES)
diff --git a/ldc/tools/CMakeLists.txt b/ldc/tools/CMakeLists.txt
index facb939472..c95b078b9c 100644
--- a/ldc/tools/CMakeLists.txt
+++ b/ldc/tools/CMakeLists.txt
@@ -25,44 +25,52 @@ install(PROGRAMS ${LDCPRUNECACHE_EXE_FULL} DESTINATION ${CMAKE_INSTALL_PREFIX}/b
#############################################################################
# Build ldc-profdata for converting profile data formats (source version depends on LLVM version)
-set(LDCPROFDATA_SRC ldc-profdata/llvm-profdata-${LLVM_VERSION_MAJOR}.${LLVM_VERSION_MINOR}.cpp)
-if (EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/${LDCPROFDATA_SRC})
- add_executable(ldc-profdata ${LDCPROFDATA_SRC})
- set_target_properties(
- ldc-profdata PROPERTIES
- RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/bin
- COMPILE_FLAGS "${LLVM_CXXFLAGS} ${LDC_CXXFLAGS}"
- LINK_FLAGS "${SANITIZE_LDFLAGS}"
- )
- target_link_libraries(ldc-profdata ${LLVM_LIBRARIES} ${CMAKE_DL_LIBS} ${LLVM_LDFLAGS})
- install(TARGETS ldc-profdata DESTINATION ${CMAKE_INSTALL_PREFIX}/bin)
-else()
- message(WARNING "ldc-profdata source (${LDCPROFDATA_SRC}) not found")
+# ENABLE_LDC_PROFGEN works for profgen and profdata
+option(ENABLE_LDC_PROFGEN "LDC-profdata feature defaults to off" OFF) # See below
+if(ENABLE_LDC_PROFGEN)
+ set(LDCPROFDATA_SRC ldc-profdata/llvm-profdata-${LLVM_VERSION_MAJOR}.${LLVM_VERSION_MINOR}.cpp)
+ if (EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/${LDCPROFDATA_SRC})
+ add_executable(ldc-profdata ${LDCPROFDATA_SRC})
+ set_target_properties(
+ ldc-profdata PROPERTIES
+ RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/bin
+ COMPILE_FLAGS "${LLVM_CXXFLAGS} ${LDC_CXXFLAGS}"
+ LINK_FLAGS "${SANITIZE_LDFLAGS}"
+ )
+ target_link_libraries(ldc-profdata ${LLVM_LIBRARIES} ${CMAKE_DL_LIBS} ${LLVM_LDFLAGS})
+ install(TARGETS ldc-profdata DESTINATION ${CMAKE_INSTALL_PREFIX}/bin)
+ else()
+ message(WARNING "ldc-profdata source (${LDCPROFDATA_SRC}) not found")
+ endif()
endif()
+
#############################################################################
# Build ldc-profgen utility that generates a profile data file from given perf script
# data files for sample-based profile guided optimization (-fprofile-sample-use).
# https://llvm.org/docs/CommandGuide/llvm-profgen.html
# The source in ldc-profgen/ldc-profgen-xx.x is an unmodified copy of llvm's llvm-profgen source dir.
-if(LDC_LLVM_VER GREATER_EQUAL 1400)
- macro(add_llvm_tool llvm_name)
- string(REPLACE "llvm-" "ldc-" ldc_name ${llvm_name})
- message(STATUS "Configuring ${ldc_name} build target")
- add_executable(${ldc_name} ${ARGN})
- set_target_properties(
- ${ldc_name} PROPERTIES
- RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/bin
- COMPILE_FLAGS "${LLVM_CXXFLAGS} ${LDC_CXXFLAGS}"
- LINK_FLAGS "${SANITIZE_LDFLAGS}"
- )
- target_link_libraries(${ldc_name} ${LLVM_LIBRARIES} ${CMAKE_DL_LIBS} ${LLVM_LDFLAGS})
- install(TARGETS ${ldc_name} DESTINATION ${CMAKE_INSTALL_PREFIX}/bin)
- endmacro()
- if (IS_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/ldc-profgen/ldc-profgen-${LLVM_VERSION_MAJOR}.${LLVM_VERSION_MINOR})
- add_subdirectory(ldc-profgen/ldc-profgen-${LLVM_VERSION_MAJOR}.${LLVM_VERSION_MINOR})
- else()
- message(WARNING "ldc-profgen source not found (${CMAKE_CURRENT_SOURCE_DIR}/ldc-profgen/ldc-profgen-${LLVM_VERSION_MAJOR}.${LLVM_VERSION_MINOR})")
+option(ENABLE_LDC_PROFGEN "LDC-profgen feature defaults to off" OFF) # See below
+if(ENABLE_LDC_PROFGEN)
+ if(LDC_LLVM_VER GREATER_EQUAL 1400)
+ macro(add_llvm_tool llvm_name)
+ string(REPLACE "llvm-" "ldc-" ldc_name ${llvm_name})
+ message(STATUS "Configuring ${ldc_name} build target")
+ add_executable(${ldc_name} ${ARGN})
+ set_target_properties(
+ ${ldc_name} PROPERTIES
+ RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/bin
+ COMPILE_FLAGS "${LLVM_CXXFLAGS} ${LDC_CXXFLAGS}"
+ LINK_FLAGS "${SANITIZE_LDFLAGS}"
+ )
+ target_link_libraries(${ldc_name} ${LLVM_LIBRARIES} ${CMAKE_DL_LIBS} ${LLVM_LDFLAGS})
+ install(TARGETS ${ldc_name} DESTINATION ${CMAKE_INSTALL_PREFIX}/bin)
+ endmacro()
+ if (IS_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/ldc-profgen/ldc-profgen-${LLVM_VERSION_MAJOR}.${LLVM_VERSION_MINOR})
+ add_subdirectory(ldc-profgen/ldc-profgen-${LLVM_VERSION_MAJOR}.${LLVM_VERSION_MINOR})
+ else()
+ message(WARNING "ldc-profgen source not found (${CMAKE_CURRENT_SOURCE_DIR}/ldc-profgen/ldc-profgen-${LLVM_VERSION_MAJOR}.${LLVM_VERSION_MINOR})")
+ endif()
endif()
endif()
Here is a diff that 'fixes' the ldc-profgen errors (by avoiding them) for several versions of linux I have tried. Not really sure if the is the best way to do this, but I think it should work for now at least. Hopefully we can fix the ldc-profgen issue later and this won't be necessary anyways.
This diff uses the
LDC_PROFGEN
environment variable to avoid building on the default build (ie. the env var is not set at all). Then one can use this env var on the CI/CD to enable the ldc-profgen compilation on the ci server viaexport LDC_PROFGEN="ENABLE_LDC_PROFGEN=ON"
or some such (not totally sure how to set things on the ci server).