Skip to content

Commit

Permalink
Apply name change to CMake build system.
Browse files Browse the repository at this point in the history
This change has the CMake build system create a dynamic library named
libomp instead of libiomp5.  Also any reference to libiomp is replaced
with libomp.  One can still use the LIBOMP_LIB_NAME variable to enforce
a different name, and everything will still work as expected.  An important
note is that libiomp5 and libgomp symlinks are created at install time when
on Unix systems.  On Windows, copies are created with the legacy names.

llvm-svn: 238715
  • Loading branch information
jpeyton52 committed Jun 1, 2015
1 parent 8fd9fb9 commit 227e1ae
Show file tree
Hide file tree
Showing 9 changed files with 103 additions and 119 deletions.
12 changes: 6 additions & 6 deletions openmp/runtime/Build_With_CMake.txt
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ Library type can be normal, profile, or stubs.
Build type can be Release, Debug, or RelWithDebInfo.

-DLIBOMP_VERSION=5|4
libiomp5 version can be 5 or 4.
libomp version can be 5 or 4.

-DLIBOMP_OMP_VERSION=40|30
OpenMP version can be either 40 or 30.
Expand Down Expand Up @@ -159,10 +159,10 @@ These tests can be turned on (default) or off with the following options:
-DLIBOMP_TEST_EXECSTACK=on|off -- Should the stack be checked for executability?
-DLIBOMP_TEST_INSTR=on|off -- Should the Intel(R) MIC Libraries be checked
for correct instruction set?
-DLIBOMP_TEST_DEPS=on|off -- Should libiomp5's dependencies be checked?
-DLIBOMP_TEST_DEPS=on|off -- Should libomp's dependencies be checked?
-DLIBOMP_MICRO_TESTS=off|on -- Should any of the above tests be done?
If -DLIBOMP_MICRO_TESTS=on is specified, the user can then call:
$ make libiomp-micro-tests
$ make libomp-micro-tests
which runs the tests.

============================================
Expand All @@ -185,9 +185,9 @@ which runs the tests.
===================================
-DLIBOMP_USE_BUILDPL_RULES=false|true
Should the build imitate build.pl's build process.
When this is true, the Unix* Release builds will build libiomp5
When this is true, the Unix* Release builds will build libomp
with -O2 and -g flags activated (same as RelWithDebInfo). Then,
the debug info is stripped out of the library and put into libiomp5.dbg
the debug info is stripped out of the library and put into libomp.dbg
This is done for interaction with Intel(R) Parallel Amplifier.

-DLIBOMP_USE_ADAPTIVE_LOCKS=true|false
Expand Down Expand Up @@ -231,7 +231,7 @@ cmake -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ -DLIBOMP_OS=mac -DLI

- Build the library (architecture determined by probing compiler) using the
Intel(R) C Compiler and the Intel(R) C++ Compiler. Also, create the fortran modules using
the Intel(R) Fortran Compiler, enabling the libiomp-micro-tests target and using similar rules that build.pl
the Intel(R) Fortran Compiler, enabling the libomp-micro-tests target and using similar rules that build.pl
would use to build the library.
cmake -DCMAKE_C_COMPILER=icc -DCMAKE_CXX_COMPILER=icpc -DCMAKE_Fortran_COMPILER=ifort -DLIBOMP_MICRO_TESTS=on -DLIBOMP_FORTRAN_MODULES=on -DLIBOMP_USE_BUILDPL_RULES=on ..

Expand Down
158 changes: 71 additions & 87 deletions openmp/runtime/CMakeLists.txt

Large diffs are not rendered by default.

26 changes: 13 additions & 13 deletions openmp/runtime/cmake/BuildPLRules.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -11,31 +11,31 @@

###############################################################################
# This file contains additional build rules that correspond to build.pl's rules.
# Building libiomp5.dbg is linux only, Windows will build libiomp5md.dll.pdb
# Building libomp.dbg is linux only, Windows will build libompmd.dll.pdb
# This file is only active if ${LIBOMP_USE_BUILDPL_RULES} is true.
#
# ######### BUILD DEPENDENCIES ##########
#
# exports/.../libiomp5.so exports/.../libiomp5.dbg
# exports/.../libomp.so exports/.../libomp.dbg
# [copy] | | [copy]
# | |
# ./libiomp5.so ./libiomp5.dbg
# ./libomp.so ./libomp.dbg
# [copy] / OR \____________ [copy] | [copy]
# / \ |
# ./unstripped/libiomp5.so ./stripped/libiomp5.so ./unstripped/libiomp5.dbg
# ./unstripped/libomp.so ./stripped/libomp.so ./unstripped/libomp.dbg
# / \ /
# / [linking] \[strip] /[strip and store]
# / \ /
# ${objs} (maybe compiled with -g) ./unstripped/libiomp5.so (library with debug info in it)
# ${objs} (maybe compiled with -g) ./unstripped/libomp.so (library with debug info in it)
# |
# | [linking]
# |
# ${objs} (always compiled with -g)
#
# For icc Linux builds, we always include debugging information via -g and create libiomp5.dbg
# For icc Linux builds, we always include debugging information via -g and create libomp.dbg
# so that Intel(R) Parallel Amplifier can use the .dbg file.
# For icc Windows builds, we always include debugging information via -Zi and create libiomp5.pdb
# in a fashion similar to libiomp5.dbg
# For icc Windows builds, we always include debugging information via -Zi and create libomp.pdb
# in a fashion similar to libomp.dbg
# For icc Mac builds, we don't bother with the debug info.

# We build library in unstripped directory
Expand Down Expand Up @@ -77,7 +77,7 @@ if(NOT "${dbg_file}" STREQUAL "")
add_custom_command(
OUTPUT ${build_dir}/unstripped/${dbg_file}
COMMAND ${CMAKE_OBJCOPY} --only-keep-debug ${build_dir}/unstripped/${lib_file} ${build_dir}/unstripped/${dbg_file}
DEPENDS iomp5
DEPENDS omp
)

else()
Expand All @@ -89,21 +89,21 @@ endif()

# Windows specific command to move around debug info files post-build
if(NOT "${pdb_file}" STREQUAL "" AND ${RELEASE_BUILD})
add_custom_command(TARGET iomp5 POST_BUILD
add_custom_command(TARGET omp POST_BUILD
COMMAND ${CMAKE_COMMAND} -E rename ${pdb_file} ${pdb_file}.nonstripped
COMMAND ${CMAKE_COMMAND} -E rename ${pdb_file}.stripped ${pdb_file}
)
endif()

# Have icc build libiomp5 in unstripped directory
set_target_properties(iomp5 PROPERTIES
# Have icc build libomp in unstripped directory
set_target_properties(omp PROPERTIES
LIBRARY_OUTPUT_DIRECTORY "${build_dir}/unstripped"
RUNTIME_OUTPUT_DIRECTORY "${build_dir}/unstripped"
ARCHIVE_OUTPUT_DIRECTORY "${build_dir}"
)

# Always use RelWithDebInfo flags for Release builds when using the build.pl's build rules (use -g -O2 instead of just -O3)
# The debug info is then stripped out at the end of the build and put into libiomp5.dbg for Linux
# The debug info is then stripped out at the end of the build and put into libomp.dbg for Linux
if(${RELEASE_BUILD} AND NOT ${MAC})
set(CMAKE_C_FLAGS_RELEASE ${CMAKE_C_FLAGS_RELWITHDEBINFO} )
set(CMAKE_CXX_FLAGS_RELEASE ${CMAKE_CXX_FLAGS_RELWITHDEBINFO})
Expand Down
2 changes: 1 addition & 1 deletion openmp/runtime/cmake/CommonFlags.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ function(append_linker_flags_common input_ld_flags input_ld_flags_libs)
# For now, always include --version-script flag on Unix systems.
append_linker_flags("-Wl,--version-script=${src_dir}/exports_so.txt") # Use exports_so.txt as version script to create versioned symbols for ELF libraries
append_linker_flags("-Wl,-z,noexecstack") # Marks the object as not requiring executable stack.
append_linker_flags("-Wl,--as-needed") # Only adds library dependencies as they are needed. (if libiomp5 actually uses a function from the library, then add it)
append_linker_flags("-Wl,--as-needed") # Only adds library dependencies as they are needed. (if libomp actually uses a function from the library, then add it)
if(NOT ${STUBS_LIBRARY})
append_linker_flags("-Wl,--warn-shared-textrel") # Warn if the linker adds a DT_TEXTREL to a shared object.
append_linker_flags("-Wl,-fini=__kmp_internal_end_fini") # When creating an ELF executable or shared object, call NAME when the
Expand Down
2 changes: 1 addition & 1 deletion openmp/runtime/cmake/Intel/AsmFlags.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ function(append_assembler_specific_asm_flags input_asm_flags)
elseif(${INTEL64})
append_asm_flags("-D _M_AMD64")
endif()
# CMake prefers the /MD flags when compiling Windows sources, but libiomp5 needs to use /MT instead
# CMake prefers the /MD flags when compiling Windows sources, but libomp needs to use /MT instead
# So we replace these /MD instances with /MT within the CMAKE_*_FLAGS variables and put that out to the CACHE.
# replace_md_with_mt() is in HelperFunctions.cmake
replace_md_with_mt(CMAKE_ASM_MASM_FLAGS)
Expand Down
2 changes: 1 addition & 1 deletion openmp/runtime/cmake/Intel/CFlags.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ function(append_compiler_specific_c_and_cxx_flags input_c_flags input_cxx_flags)
endif()
endif()
endif()
# CMake prefers the /MD flags when compiling Windows sources, but libiomp5 needs to use /MT instead
# CMake prefers the /MD flags when compiling Windows sources, but libomp needs to use /MT instead
# So we replace these /MD instances with /MT within the CMAKE_*_FLAGS variables and put that out to the CACHE.
# replace_md_with_mt() is in HelperFunctions.cmake
if(${WINDOWS})
Expand Down
2 changes: 1 addition & 1 deletion openmp/runtime/cmake/MSVC/AsmFlags.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ function(append_assembler_specific_asm_flags input_asm_flags)
elseif(${INTEL64})
append_asm_flags("-D _M_AMD64")
endif()
# CMake prefers the /MD flags when compiling Windows sources, but libiomp5 needs to use /MT instead
# CMake prefers the /MD flags when compiling Windows sources, but libomp needs to use /MT instead
# So we replace these /MD instances with /MT within the CMAKE_*_FLAGS variables and put that out to the CACHE.
# replace_md_with_mt() is in HelperFunctions.cmake
replace_md_with_mt(CMAKE_ASM_MASM_FLAGS)
Expand Down
2 changes: 1 addition & 1 deletion openmp/runtime/cmake/MSVC/CFlags.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ function(append_compiler_specific_c_and_cxx_flags input_c_flags input_cxx_flags)
append_c_and_cxx_flags("-arch:ia32") # Tells the compiler which features it may target (ia32)
append_c_and_cxx_flags("-Oy-") # equivalent to -fno-omit-frame-pointer
endif()
# CMake prefers the /MD flags when compiling Windows sources, but libiomp5 needs to use /MT instead
# CMake prefers the /MD flags when compiling Windows sources, but libomp needs to use /MT instead
# So we replace these /MD instances with /MT within the CMAKE_*_FLAGS variables and put that out to the CACHE.
# replace_md_with_mt() is in HelperFunctions.cmake
replace_md_with_mt(CMAKE_C_FLAGS)
Expand Down
16 changes: 8 additions & 8 deletions openmp/runtime/cmake/MicroTests.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@
# the library just created in ${build_dir}/, there are currently
# five micro-tests:
# (1) test-touch
# - Compile and run a small program using newly created libiomp5 library
# - Compile and run a small program using newly created libomp library
# - Fails if test-touch.c does not compile or if test-touch.c does not run after compilation
# - Program dependencies: gcc or g++, grep, bourne shell
# - Available for all Linux,Mac,Windows builds. Not available on Intel(R) MIC Architecture builds.
# (2) test-relo
# - Tests dynamic libraries for position-dependent code (can not have any position dependent code)
# - Fails if TEXTREL is in output of readelf -d libiomp5.so command
# - Fails if TEXTREL is in output of readelf -d libomp.so command
# - Program dependencies: readelf, grep, bourne shell
# - Available for Linux, Intel(R) MIC Architecture dynamic library builds. Not available otherwise.
# (3) test-execstack
Expand All @@ -35,7 +35,7 @@
# - Program dependencies: perl, objdump
# - Available for Intel(R) MIC Architecture builds. Not available otherwise.
# (5) test-deps
# - Tests newly created libiomp5 for library dependencies
# - Tests newly created libomp for library dependencies
# - Fails if sees a dependence not listed in td_exp variable below
# - Program dependencies: perl, (linux)readelf, (mac)otool[64], (windows)link.exe
# - Available for Linux,Mac,Windows, Intel(R) MIC Architecture dynamic builds and Windows static builds. Not available otherwise.
Expand All @@ -58,7 +58,7 @@ set(regular_test_touch_items "${test_touch_items}")
add_suffix("/.success" regular_test_touch_items)
# test-touch : ${test_touch_items}/.success
set(ldeps "${regular_test_touch_items}")
add_custom_target(libiomp-test-touch DEPENDS ${ldeps})
add_custom_target(libomp-test-touch DEPENDS ${ldeps})

if(${WINDOWS})
# pick test-touch compiler
Expand Down Expand Up @@ -138,7 +138,7 @@ else()
endif()

# test-relo
add_custom_target(libiomp-test-relo DEPENDS test-relo/.success)
add_custom_target(libomp-test-relo DEPENDS test-relo/.success)
add_custom_command(
OUTPUT test-relo/.success
COMMAND ${CMAKE_COMMAND} -E make_directory ${build_dir}/test-relo
Expand All @@ -149,7 +149,7 @@ add_custom_command(
)

# test-execstack
add_custom_target(libiomp-test-execstack DEPENDS test-execstack/.success)
add_custom_target(libomp-test-execstack DEPENDS test-execstack/.success)
add_custom_command(
OUTPUT test-execstack/.success
COMMAND ${CMAKE_COMMAND} -E make_directory ${build_dir}/test-execstack
Expand All @@ -159,7 +159,7 @@ add_custom_command(
)

# test-instr
add_custom_target(libiomp-test-instr DEPENDS test-instr/.success)
add_custom_target(libomp-test-instr DEPENDS test-instr/.success)
add_custom_command(
OUTPUT test-instr/.success
COMMAND ${CMAKE_COMMAND} -E make_directory ${build_dir}/test-instr
Expand All @@ -169,7 +169,7 @@ add_custom_command(
)

# test-deps
add_custom_target(libiomp-test-deps DEPENDS test-deps/.success)
add_custom_target(libomp-test-deps DEPENDS test-deps/.success)
set(td_exp)
if(${FREEBSD})
set(td_exp libc.so.7 libthr.so.3 libunwind.so.5)
Expand Down

0 comments on commit 227e1ae

Please sign in to comment.