Remove -fvisibility=hidden and FORCE_STATIC.
authorMichael Kruse <llvm@meinersbur.de>
Mon, 12 Sep 2016 18:25:00 +0000 (18:25 +0000)
committerMichael Kruse <llvm@meinersbur.de>
Mon, 12 Sep 2016 18:25:00 +0000 (18:25 +0000)
The flag -fvisibility=hidden flag was used for the integrated Integer
Set Library (and PPCG) to keep their definitions local to Polly. The
motivation was the be loaded into a DragonEgg-powered GCC, where GCC
might itself use ISL for its Graphite extension. The symbols of Polly's
ISL and GCC's ISL would clash.

The DragonEgg project is not actively developed anymore, but Polly's
unittests need to call ISL functions to set up a testing environment.
Unfortunately, the -fvisibility=hidden flag means that the ISL symbols
are not available to the gtest executable as it resides outside of
libPolly when linked dynamically. Currently, CMake links a second copy
of ISL into the unittests which leads to subtle bugs. What got observed
is that two isl_ids for isl_id_none exist, one for each library
instance. Because isl_id's are compared by address, isl_id_none could
happen to be different from isl_id_none, depending on which library
instance set the address and does the comparison.

Also remove the FORCE_STATIC flag which was introduced to keep the ISL
symbols visible inside the same libPolly shared object, even when build
with BUILD_SHARED_LIBS.

Differential Revision: https://reviews.llvm.org/D24460

llvm-svn: 281242

polly/cmake/polly_macros.cmake
polly/lib/External/CMakeLists.txt

index e059ae6..32bed50 100644 (file)
@@ -2,7 +2,7 @@
 include(CMakeParseArguments)
 
 macro(add_polly_library name)
-  cmake_parse_arguments(ARG "FORCE_STATIC" "" "" ${ARGN})
+  cmake_parse_arguments(ARG "" "" "" ${ARGN})
   set(srcs ${ARG_UNPARSED_ARGUMENTS})
   if(MSVC_IDE OR XCODE)
     file( GLOB_RECURSE headers *.h *.td *.def)
@@ -15,12 +15,6 @@ macro(add_polly_library name)
   endif(MSVC_IDE OR XCODE)
   if (MODULE)
     set(libkind MODULE)
-  elseif (ARG_FORCE_STATIC)
-    if (SHARED_LIBRARY OR BUILD_SHARED_LIBS)
-      message(STATUS "${name} is being built as static library because it is compiled with -fvisibility=hidden; "
-                     "Its symbols are not visible from outside a shared library")
-    endif ()
-    set(libkind STATIC)
   elseif (SHARED_LIBRARY)
     set(libkind SHARED)
   else()
index fe77e75..d6ed85d 100644 (file)
@@ -256,7 +256,7 @@ set (ISL_FILES
     isl/imath/imrat.c
     )
 
-add_polly_library(PollyISL FORCE_STATIC
+add_polly_library(PollyISL
   ${ISL_FILES}
 )
 
@@ -274,19 +274,10 @@ endif ()
 # ISL requires at least C99 to compile. gcc < 5.0 use -std=gnu89 as default.
 target_enable_c99(PollyISL)
 
-# Define the FLAGS for the compilation of isl and imath
-#
-# We first set the visibility of all isl functions to hidden to ensure we do
-# not clash with other isl versions that got linked into a program that uses
-# Polly. (This happens e.g when linking Polly with dragonegg)
-#
-# This is the reason for the FORCE_STATIC flag above; without it, not even Polly
-# could access ISL's symbols in shared library builds.
-#
-# We also disable warnings which should be coped with upstream.
+# Disable warnings which should be coped with upstream for isl and imath.
 if (NOT MSVC)
   set_target_properties(PollyISL PROPERTIES
-    COMPILE_FLAGS "-fvisibility=hidden -w"
+    COMPILE_FLAGS "-w"
   )
 endif ()
 
@@ -332,12 +323,12 @@ include_directories(BEFORE
   ${PET_SOURCE_DIR}/include
 )
 
-add_polly_library(PollyPPCG FORCE_STATIC
+add_polly_library(PollyPPCG
   ${PPCG_FILES}
 )
 
 if (NOT MSVC)
   set_target_properties(PollyPPCG PROPERTIES
-    COMPILE_FLAGS "-fvisibility=hidden -w"
+    COMPILE_FLAGS "-w"
   )
 endif ()