Skip to content

Commit 30ce6fb

Browse files
author
Vadim Paretsky
committed
[OpenMP] Fix an OpenMP Windows build problem
When building OpenMP as part of LLVM, CMAKE was generating incorrect location references for OpenMP build's first step's artifacts being used in regenerating its Windows import library in the second step. The fix is to feed a dummy non-buildable, rather than buildable, source to CMAKE to satisfy its source requirements removing the need to reference the first step's artifacts in the second step altogether. Differential Revision:https://reviews.llvm.org/D146894
1 parent 1b56f27 commit 30ce6fb

File tree

2 files changed

+18
-6
lines changed

2 files changed

+18
-6
lines changed

openmp/runtime/src/CMakeLists.txt

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -295,14 +295,13 @@ if(WIN32)
295295
-o ${LIBOMPIMP_GENERATED_DEF_FILE} ${CMAKE_CURRENT_SOURCE_DIR}/dllexports
296296
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/dllexports ${LIBOMP_TOOLS_DIR}/generate-def.pl
297297
)
298-
# while this is merely generating an import library off the one generated with the runtime dll,
299-
# kmp_global.cpp will satisfy the librarian's apparent ask to see the actual exported DATA items
300-
set_source_files_properties(${LIBOMP_GENERATED_IMP_LIB_FILENAME} PROPERTIES GENERATED TRUE EXTERNAL_OBJECT TRUE)
301-
add_library(${LIBOMP_IMP_LIB_TARGET} STATIC ${LIBOMP_GENERATED_IMP_LIB_FILENAME} kmp_global.cpp)
298+
# while this merely generates an import library off a def file, CMAKE still requires it to have a "source" so feed it a dummy one,
299+
# making it a .txt which CMAKE will filter out from the librarian (a .cpp will make lib.exe punt trying to resolve the .def symbols)
300+
add_library(${LIBOMP_IMP_LIB_TARGET} STATIC kmp_dummy.txt)
302301
set_target_properties(${LIBOMP_IMP_LIB_TARGET} PROPERTIES
303-
PREFIX "" SUFFIX "" OUTPUT_NAME "${LIBOMP_IMP_LIB_FILE}" LINKER_LANGUAGE C
302+
PREFIX "" SUFFIX "" OUTPUT_NAME "${LIBOMP_IMP_LIB_FILE}" LINKER_LANGUAGE ${LIBOMP_LINKER_LANGUAGE}
304303
STATIC_LIBRARY_OPTIONS "${CMAKE_LINK_DEF_FILE_FLAG}${CMAKE_CURRENT_BINARY_DIR}/${LIBOMPIMP_GENERATED_DEF_FILE}")
305-
add_dependencies(${LIBOMP_IMP_LIB_TARGET} omp libompimp-needed-def-file)
304+
add_dependencies(${LIBOMP_IMP_LIB_TARGET} libompimp-needed-def-file)
306305
endif()
307306
endif()
308307

openmp/runtime/src/kmp_dummy.txt

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
/*
2+
* kmp_dummy.txt -- dummy "source" file used in regenerating the Windows import library
3+
*/
4+
5+
//===----------------------------------------------------------------------===//
6+
//
7+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
8+
// See https://llvm.org/LICENSE.txt for license information.
9+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
10+
//
11+
//===----------------------------------------------------------------------===//
12+
13+
// end of file //

0 commit comments

Comments
 (0)