Re: [cmake-developers] patch that adds -KPIC flag to SunPro Fortran compiler
On 03/24/2015 04:38 AM, Steven Vancoillie wrote: On Mar 23 [10:33], Brad King wrote: * The _VERBOSE_FLAG is -v for most languages and -# for ASM. The verbose flags for SunPro compilers are documented as: Sun C compiler: -# (-v enables stricter semantic checks) Sun CXX compiler: -# (-v turns on -verbose=diags, seems similar) Sun ASM compiler: none (-v/-# are not recognized) Sun Fortran compiler: -v (-# works too) Since the current verbose flags are thus not correct, I've left this alone in this patch, as it should be pure refactoring. Maybe they can go in a separate patch? Okay. The purpose of this flag for CMake is to be able to see the ld invocation that the compiler front-end produces. This is used while enabling a language to collect the implicit linker search paths and libraries that the compiler front-end uses. We can change the flags from their current setting as long as this works. Look at CMakeFiles/*/CMake*Compiler.cmake for the detection results and in CMakeFiles/CMakeOutput.log for a log of the extraction process. Please first create a patch to fix all the flags with corresponding explanations and documentation references. Then a second patch can do the refactoring and consolidation of duplicate flags. The _CREATE_PREPROCESSED_SOURCE rule for Fortran is now overwritten again in the Fortran-specific file to use the -F option. Good. I've attached the new patch. This does not strictly follow your rule, as now there will be a CMAKE_ASM_COMPILE_OPTIONS_PIC variable set because of the macro (before this was not set). Should I unset it again in the ASM-specific file? Yes. If there is no verbose flag for ASM either then that should be unset too. Thanks, -Brad -- Powered by www.kitware.com Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ Kitware offers various services to support the CMake community. For more information on each offering, please visit: CMake Support: http://cmake.org/cmake/help/support.html CMake Consulting: http://cmake.org/cmake/help/consulting.html CMake Training Courses: http://cmake.org/cmake/help/training.html Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html Follow this link to subscribe/unsubscribe: http://public.kitware.com/mailman/listinfo/cmake-developers
Re: [cmake-developers] patch that adds -KPIC flag to SunPro Fortran compiler
On Mar 23 [10:33], Brad King wrote: On 03/23/2015 04:37 AM, Steven Vancoillie wrote: Thanks. I split out the -KPIE removal: SunPro: Drop non-existent -KPIE flag http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=209c142f Please rebase the revisions below on that. The current patch does not account for differences in the flags for each language: * The _VERBOSE_FLAG is -v for most languages and -# for ASM. The verbose flags for SunPro compilers are documented as: Sun C compiler: -# (-v enables stricter semantic checks) Sun CXX compiler: -# (-v turns on -verbose=diags, seems similar) Sun ASM compiler: none (-v/-# are not recognized) Sun Fortran compiler: -v (-# works too) Since the current verbose flags are thus not correct, I've left this alone in this patch, as it should be pure refactoring. Maybe they can go in a separate patch? * The _CREATE_PREPROCESSED_SOURCE rule for Fortran uses -F instead of -E. The _CREATE_PREPROCESSED_SOURCE rule for Fortran is now overwritten again in the Fortran-specific file to use the -F option. Please revise the patch accordingly and check that the values set after refactoring match those from before. It is okay for flags that are not shared by all languages to be set as they are now or overridden after the macro call. I've attached the new patch. This does not strictly follow your rule, as now there will be a CMAKE_ASM_COMPILE_OPTIONS_PIC variable set because of the macro (before this was not set). Should I unset it again in the ASM-specific file? Steven From f524d09ae0b8315fded0299866da6770e76144af Mon Sep 17 00:00:00 2001 From: Steven Vancoillie steven.vancoil...@teokem.lu.se Date: Tue, 24 Mar 2015 09:10:31 +0100 Subject: [PATCH] Refactor SunPro per-language options into single macro Move SunPro compiler options that are shared between languages into a single macro inside a languange-independent helper module Compiler/SunPro.cmake which is then invoked from the per-language modules Compiler/SunPro-lang.cmake --- Modules/Compiler/SunPro-ASM.cmake | 10 - Modules/Compiler/SunPro-C.cmake | 14 Modules/Compiler/SunPro-CXX.cmake | 15 + Modules/Compiler/SunPro-Fortran.cmake | 12 --- Modules/Compiler/SunPro.cmake | 40 +++ 5 files changed, 41 insertions(+), 50 deletions(-) create mode 100644 Modules/Compiler/SunPro.cmake diff --git a/Modules/Compiler/SunPro-ASM.cmake b/Modules/Compiler/SunPro-ASM.cmake index 2fa8b99..fd7c5ab 100644 --- a/Modules/Compiler/SunPro-ASM.cmake +++ b/Modules/Compiler/SunPro-ASM.cmake @@ -2,17 +2,7 @@ set(CMAKE_ASM_SOURCE_FILE_EXTENSIONS s ) set(CMAKE_ASM_VERBOSE_FLAG -#) -set(CMAKE_SHARED_LIBRARY_ASM_FLAGS -KPIC) -set(CMAKE_SHARED_LIBRARY_CREATE_ASM_FLAGS -G) -set(CMAKE_SHARED_LIBRARY_RUNTIME_ASM_FLAG -R) -set(CMAKE_SHARED_LIBRARY_RUNTIME_ASM_FLAG_SEP :) -set(CMAKE_SHARED_LIBRARY_SONAME_ASM_FLAG -h) -set(CMAKE_ASM_FLAGS_INIT ) -set(CMAKE_ASM_FLAGS_DEBUG_INIT -g) -set(CMAKE_ASM_FLAGS_MINSIZEREL_INIT -xO2 -xspace -DNDEBUG) -set(CMAKE_ASM_FLAGS_RELEASE_INIT -xO3 -DNDEBUG) -set(CMAKE_ASM_FLAGS_RELWITHDEBINFO_INIT -g -xO2 -DNDEBUG) # Initialize ASM link type selection flags. These flags are used when # building a shared library, shared module, or executable that links diff --git a/Modules/Compiler/SunPro-C.cmake b/Modules/Compiler/SunPro-C.cmake index 92252cb..ed2c927 100644 --- a/Modules/Compiler/SunPro-C.cmake +++ b/Modules/Compiler/SunPro-C.cmake @@ -1,17 +1,6 @@ set(CMAKE_C_VERBOSE_FLAG -#) -set(CMAKE_C_COMPILE_OPTIONS_PIC -KPIC) -set(CMAKE_SHARED_LIBRARY_C_FLAGS -KPIC) -set(CMAKE_SHARED_LIBRARY_CREATE_C_FLAGS -G) -set(CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG -R) -set(CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG_SEP :) -set(CMAKE_SHARED_LIBRARY_SONAME_C_FLAG -h) -set(CMAKE_C_FLAGS_INIT ) -set(CMAKE_C_FLAGS_DEBUG_INIT -g) -set(CMAKE_C_FLAGS_MINSIZEREL_INIT -xO2 -xspace -DNDEBUG) -set(CMAKE_C_FLAGS_RELEASE_INIT -xO3 -DNDEBUG) -set(CMAKE_C_FLAGS_RELWITHDEBINFO_INIT -g -xO2 -DNDEBUG) # Initialize C link type selection flags. These flags are used when # building a shared library, shared module, or executable that links @@ -21,6 +10,3 @@ foreach(type SHARED_LIBRARY SHARED_MODULE EXE) set(CMAKE_${type}_LINK_STATIC_C_FLAGS -Bstatic) set(CMAKE_${type}_LINK_DYNAMIC_C_FLAGS -Bdynamic) endforeach() - -set(CMAKE_C_CREATE_PREPROCESSED_SOURCE CMAKE_C_COMPILER DEFINES FLAGS -E SOURCE PREPROCESSED_SOURCE) -set(CMAKE_C_CREATE_ASSEMBLY_SOURCE CMAKE_C_COMPILER DEFINES FLAGS -S SOURCE -o ASSEMBLY_SOURCE) diff --git a/Modules/Compiler/SunPro-CXX.cmake b/Modules/Compiler/SunPro-CXX.cmake index 022b4d4..a3f0c6b 100644 --- a/Modules/Compiler/SunPro-CXX.cmake +++ b/Modules/Compiler/SunPro-CXX.cmake @@ -1,17 +1,6 @@ set(CMAKE_CXX_VERBOSE_FLAG -v) -set(CMAKE_CXX_COMPILE_OPTIONS_PIC -KPIC) -set(CMAKE_SHARED_LIBRARY_CXX_FLAGS -KPIC) -set(CMAKE_SHARED_LIBRARY_CREATE_CXX_FLAGS -G)
Re: [cmake-developers] patch that adds -KPIC flag to SunPro Fortran compiler
On Mar 20 [13:08], Brad King wrote: On 03/20/2015 04:23 AM, Steven Vancoillie wrote: Looking at other compiler configurations, it seems it might be better to have a SunPro.cmake module that combines flags that are independent of the language? Yes. This refactoring has simply not been done for this compiler. If you want to work on it, please note that such a module is not loaded automatically and must be included by the per-language modules. This pattern is visible in several other compiler modules. I've included a candidate patch for this refactoring. I also noticed the follow variables are set for C, CSS, and ASM: set(CMAKE_${type}_LINK_STATIC_${lang}_FLAGS -Bstatic) set(CMAKE_${type}_LINK_DYNAMIC_${lang}_FLAGS -Bdynamic) I could add these for Fortran as well and move it also to the macro in SunPro.cmake. However, since this only seems to be there for SunPro, I wondered if these are used at all? These options are just passed to ld, so they are not sun-specific. grtz Steven From b541e110cdc3404ac7b5ac0c24f501c2216058bb Mon Sep 17 00:00:00 2001 From: Steven Vancoillie steven.vancoil...@teokem.lu.se Date: Mon, 23 Mar 2015 09:22:14 +0100 Subject: [PATCH] Combine SunPro compiler flags for multiple languages Merge equivalent compiler flags into one single SunPro.cmake file, which are then imported into the per-language modules. This also removes the non-existent -KPIE option. --- Modules/Compiler/SunPro-ASM.cmake | 17 +++--- Modules/Compiler/SunPro-C.cmake | 20 ++--- Modules/Compiler/SunPro-CXX.cmake | 21 ++ Modules/Compiler/SunPro-Fortran.cmake | 17 +++--- Modules/Compiler/SunPro.cmake | 42 +++ 5 files changed, 52 insertions(+), 65 deletions(-) create mode 100644 Modules/Compiler/SunPro.cmake diff --git a/Modules/Compiler/SunPro-ASM.cmake b/Modules/Compiler/SunPro-ASM.cmake index 2fa8b99..fc17271 100644 --- a/Modules/Compiler/SunPro-ASM.cmake +++ b/Modules/Compiler/SunPro-ASM.cmake @@ -1,18 +1,7 @@ -set(CMAKE_ASM_SOURCE_FILE_EXTENSIONS s ) - -set(CMAKE_ASM_VERBOSE_FLAG -#) +include(Compiler/SunPro) +__compiler_sunpro(ASM) -set(CMAKE_SHARED_LIBRARY_ASM_FLAGS -KPIC) -set(CMAKE_SHARED_LIBRARY_CREATE_ASM_FLAGS -G) -set(CMAKE_SHARED_LIBRARY_RUNTIME_ASM_FLAG -R) -set(CMAKE_SHARED_LIBRARY_RUNTIME_ASM_FLAG_SEP :) -set(CMAKE_SHARED_LIBRARY_SONAME_ASM_FLAG -h) - -set(CMAKE_ASM_FLAGS_INIT ) -set(CMAKE_ASM_FLAGS_DEBUG_INIT -g) -set(CMAKE_ASM_FLAGS_MINSIZEREL_INIT -xO2 -xspace -DNDEBUG) -set(CMAKE_ASM_FLAGS_RELEASE_INIT -xO3 -DNDEBUG) -set(CMAKE_ASM_FLAGS_RELWITHDEBINFO_INIT -g -xO2 -DNDEBUG) +set(CMAKE_ASM_SOURCE_FILE_EXTENSIONS s ) # Initialize ASM link type selection flags. These flags are used when # building a shared library, shared module, or executable that links diff --git a/Modules/Compiler/SunPro-C.cmake b/Modules/Compiler/SunPro-C.cmake index c5b5203..a065d75 100644 --- a/Modules/Compiler/SunPro-C.cmake +++ b/Modules/Compiler/SunPro-C.cmake @@ -1,18 +1,5 @@ -set(CMAKE_C_VERBOSE_FLAG -#) - -set(CMAKE_C_COMPILE_OPTIONS_PIC -KPIC) -set(CMAKE_C_COMPILE_OPTIONS_PIE -KPIE) -set(CMAKE_SHARED_LIBRARY_C_FLAGS -KPIC) -set(CMAKE_SHARED_LIBRARY_CREATE_C_FLAGS -G) -set(CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG -R) -set(CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG_SEP :) -set(CMAKE_SHARED_LIBRARY_SONAME_C_FLAG -h) - -set(CMAKE_C_FLAGS_INIT ) -set(CMAKE_C_FLAGS_DEBUG_INIT -g) -set(CMAKE_C_FLAGS_MINSIZEREL_INIT -xO2 -xspace -DNDEBUG) -set(CMAKE_C_FLAGS_RELEASE_INIT -xO3 -DNDEBUG) -set(CMAKE_C_FLAGS_RELWITHDEBINFO_INIT -g -xO2 -DNDEBUG) +include(Compiler/SunPro) +__compiler_sunpro(C) # Initialize C link type selection flags. These flags are used when # building a shared library, shared module, or executable that links @@ -22,6 +9,3 @@ foreach(type SHARED_LIBRARY SHARED_MODULE EXE) set(CMAKE_${type}_LINK_STATIC_C_FLAGS -Bstatic) set(CMAKE_${type}_LINK_DYNAMIC_C_FLAGS -Bdynamic) endforeach() - -set(CMAKE_C_CREATE_PREPROCESSED_SOURCE CMAKE_C_COMPILER DEFINES FLAGS -E SOURCE PREPROCESSED_SOURCE) -set(CMAKE_C_CREATE_ASSEMBLY_SOURCE CMAKE_C_COMPILER DEFINES FLAGS -S SOURCE -o ASSEMBLY_SOURCE) diff --git a/Modules/Compiler/SunPro-CXX.cmake b/Modules/Compiler/SunPro-CXX.cmake index c7bc734..fee75f3 100644 --- a/Modules/Compiler/SunPro-CXX.cmake +++ b/Modules/Compiler/SunPro-CXX.cmake @@ -1,19 +1,5 @@ -set(CMAKE_CXX_VERBOSE_FLAG -v) - -set(CMAKE_CXX_COMPILE_OPTIONS_PIC -KPIC) -set(CMAKE_CXX_COMPILE_OPTIONS_PIE -KPIE) -set(CMAKE_SHARED_LIBRARY_CXX_FLAGS -KPIC) -set(CMAKE_SHARED_LIBRARY_CREATE_CXX_FLAGS -G) -set(CMAKE_SHARED_LIBRARY_RUNTIME_CXX_FLAG -R) -set(CMAKE_SHARED_LIBRARY_RUNTIME_CXX_FLAG_SEP :) -set(CMAKE_SHARED_LIBRARY_SONAME_CXX_FLAG -h) - -set(CMAKE_CXX_FLAGS_INIT ) -set(CMAKE_CXX_FLAGS_DEBUG_INIT -g) -set(CMAKE_CXX_FLAGS_MINSIZEREL_INIT -xO2 -xspace -DNDEBUG) -set(CMAKE_CXX_FLAGS_RELEASE_INIT -xO3 -DNDEBUG) -set(CMAKE_CXX_FLAGS_RELWITHDEBINFO_INIT -g -xO2 -DNDEBUG) - +include(Compiler/SunPro)
[cmake-developers] patch that adds -KPIC flag to SunPro Fortran compiler
Hi, I ran into a problem with SunPro Fortran compiler not being able to create a shared library since the -KPIC flag was missing. The patch that is attached fixes this. I didn't add a -KPIE as that doesn't exist for SunPro. Looking at other compiler configurations, it seems it might be better to have a SunPro.cmake module that combines flags that are independent of the language? greetings, Steven -- Steven Vancoillie Theoretical Chemistry Lund University P.O.B 124 S-221 00 Lund Sweden From f4efea633c55e384454e2f879144fa621510d6bb Mon Sep 17 00:00:00 2001 From: Steven Vancoillie steven.vancoil...@runbox.com Date: Fri, 20 Mar 2015 09:13:00 +0100 Subject: [PATCH] Add position independent code flag for SunPro Fortran compiler. --- Modules/Compiler/SunPro-Fortran.cmake | 1 + 1 file changed, 1 insertion(+) diff --git a/Modules/Compiler/SunPro-Fortran.cmake b/Modules/Compiler/SunPro-Fortran.cmake index e4db1e8..196aae4 100644 --- a/Modules/Compiler/SunPro-Fortran.cmake +++ b/Modules/Compiler/SunPro-Fortran.cmake @@ -2,6 +2,7 @@ set(CMAKE_Fortran_VERBOSE_FLAG -v) set(CMAKE_Fortran_FORMAT_FIXED_FLAG -fixed) set(CMAKE_Fortran_FORMAT_FREE_FLAG -free) +set(CMAKE_Fortran_COMPILE_OPTIONS_PIC -KPIC) set(CMAKE_SHARED_LIBRARY_Fortran_FLAGS -KPIC) set(CMAKE_SHARED_LIBRARY_CREATE_Fortran_FLAGS -G) set(CMAKE_SHARED_LIBRARY_RUNTIME_Fortran_FLAG -R) -- 2.3.3 -- Powered by www.kitware.com Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ Kitware offers various services to support the CMake community. For more information on each offering, please visit: CMake Support: http://cmake.org/cmake/help/support.html CMake Consulting: http://cmake.org/cmake/help/consulting.html CMake Training Courses: http://cmake.org/cmake/help/training.html Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html Follow this link to subscribe/unsubscribe: http://public.kitware.com/mailman/listinfo/cmake-developers
Re: [cmake-developers] patch that adds -KPIC flag to SunPro Fortran compiler
On 03/20/2015 04:23 AM, Steven Vancoillie wrote: I ran into a problem with SunPro Fortran compiler not being able to create a shared library since the -KPIC flag was missing. The patch that is attached fixes this. I didn't add a -KPIE as that doesn't exist for SunPro. Applied, thanks: SunPro: Add position independent code flag for Fortran compiler http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=3556fb1b Looking at other compiler configurations, it seems it might be better to have a SunPro.cmake module that combines flags that are independent of the language? Yes. This refactoring has simply not been done for this compiler. If you want to work on it, please note that such a module is not loaded automatically and must be included by the per-language modules. This pattern is visible in several other compiler modules. Thanks, -Brad -- Powered by www.kitware.com Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ Kitware offers various services to support the CMake community. For more information on each offering, please visit: CMake Support: http://cmake.org/cmake/help/support.html CMake Consulting: http://cmake.org/cmake/help/consulting.html CMake Training Courses: http://cmake.org/cmake/help/training.html Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html Follow this link to subscribe/unsubscribe: http://public.kitware.com/mailman/listinfo/cmake-developers