[llvm] r200301 - [CMake] Enhance llvm_update_compile_flags(name sources) to handle LLVM_REQUIRES_EH and LLVM_REQUIRES_RTTI.

Alexey Samsonov samsonov at google.com
Thu Jan 30 23:55:23 PST 2014


Looks like it helps, thanks!


On Fri, Jan 31, 2014 at 3:58 AM, NAKAMURA Takumi <geek4civic at gmail.com>wrote:

> Alexey, I think I have fixed in r200499.
> Sorry for the breakage and thank you to let me know.
>
> 2014-01-30 Alexey Samsonov <samsonov at google.com>:
> > Hi,
> >
> > Now LLVM_COMPILE_FLAGS set in add_unittest is ignored, and I see a bunch
> of
> > warnings:
> > /llvm/utils/unittest/googletest/include/gtest/gtest-typed-test.h:239:47:
> > warning: anonymous variadic macros were introduced in C99
> > [-Wvariadic-macros]
> >
> >
> >
> > On Tue, Jan 28, 2014 at 1:44 PM, NAKAMURA Takumi <geek4civic at gmail.com>
> > wrote:
> >>
> >> Author: chapuni
> >> Date: Tue Jan 28 03:44:06 2014
> >> New Revision: 200301
> >>
> >> URL: http://llvm.org/viewvc/llvm-project?rev=200301&view=rev
> >> Log:
> >> [CMake] Enhance llvm_update_compile_flags(name sources) to handle
> >> LLVM_REQUIRES_EH and LLVM_REQUIRES_RTTI.
> >>
> >> LLVM_REQUIRES_EH implies LLVM_REQUIRES_RTTI. It is as same behavior as
> >> Makefile.rule's.
> >> llvm/examples/ExceptionDemo is affected. (It was built with -fno-rtti.)
> >>
> >> For MSVC, Remove flags like "/EHsc /GR" in HandleLLVMOptions, or CL.EXE
> >> complains with flags like "/GR /GR-".
> >>
> >> llvm_update_compile_flags() updates source file property if the target
> >> contains *.c.
> >> COMPILE_FLAGS in target properties affects both C++ and C!
> >>
> >> LLVM_NO_RTTI is deprecated. It was introduced by me and was my mistake.
> >>
> >> Modified:
> >>     llvm/trunk/cmake/modules/AddLLVM.cmake
> >>     llvm/trunk/cmake/modules/HandleLLVMOptions.cmake
> >>
> >> Modified: llvm/trunk/cmake/modules/AddLLVM.cmake
> >> URL:
> >>
> http://llvm.org/viewvc/llvm-project/llvm/trunk/cmake/modules/AddLLVM.cmake?rev=200301&r1=200300&r2=200301&view=diff
> >>
> >>
> ==============================================================================
> >> --- llvm/trunk/cmake/modules/AddLLVM.cmake (original)
> >> +++ llvm/trunk/cmake/modules/AddLLVM.cmake Tue Jan 28 03:44:06 2014
> >> @@ -3,20 +3,45 @@ include(LLVMProcessSources)
> >>  include(LLVM-Config)
> >>
> >>  function(llvm_update_compile_flags name)
> >> -  get_property(target_compile_flags TARGET ${name} PROPERTY
> >> COMPILE_FLAGS)
> >> -  if(NOT "${LLVM_COMPILE_FLAGS}" STREQUAL "")
> >> -    set(target_compile_flags "${target_compile_flags}
> >> ${LLVM_COMPILE_FLAGS}")
> >> +  set(ALL_SOURCES ${ARGN})
> >> +  if("${ALL_SOURCES}" MATCHES "\\.c(;|$)")
> >> +    set(update_src_props ON)
> >>    endif()
> >> -  if(LLVM_NO_RTTI)
> >> +
> >> +  if(LLVM_REQUIRES_EH)
> >> +    set(LLVM_REQUIRES_RTTI ON)
> >> +  else()
> >> +    if(LLVM_COMPILER_IS_GCC_COMPATIBLE)
> >> +      set(target_compile_flags "${target_compile_flags}
> -fno-exceptions")
> >> +    elseif(MSVC)
> >> +      list(APPEND LLVM_COMPILE_DEFINITIONS _HAS_EXCEPTIONS=0)
> >> +      set(target_compile_flags "${target_compile_flags} /EHs-c-")
> >> +    endif()
> >> +  endif()
> >> +
> >> +  if(NOT LLVM_REQUIRES_RTTI)
> >>      list(APPEND LLVM_COMPILE_DEFINITIONS GTEST_HAS_RTTI=0)
> >>      if (LLVM_COMPILER_IS_GCC_COMPATIBLE)
> >>        set(target_compile_flags "${target_compile_flags} -fno-rtti")
> >>      elseif (MSVC)
> >> -      llvm_replace_compiler_option(target_compile_flags "/GR" "/GR-")
> >> +      set(target_compile_flags "${target_compile_flags} /GR-")
> >>      endif ()
> >>    endif()
> >>
> >> -  set_property(TARGET ${name} PROPERTY COMPILE_FLAGS
> >> "${target_compile_flags}")
> >> +  if(update_src_props)
> >> +    foreach(fn ${ALL_SOURCES})
> >> +      get_filename_component(suf ${fn} EXT)
> >> +      if("${suf}" STREQUAL ".cpp")
> >> +       set_property(SOURCE ${fn} APPEND_STRING PROPERTY
> >> +         COMPILE_FLAGS "${target_compile_flags}")
> >> +      endif()
> >> +    endforeach()
> >> +  else()
> >> +    # Update target props, since all sources are C++.
> >> +    set_property(TARGET ${name} APPEND_STRING PROPERTY
> >> +      COMPILE_FLAGS "${target_compile_flags}")
> >> +  endif()
> >> +
> >>    set_property(TARGET ${name} APPEND PROPERTY COMPILE_DEFINITIONS
> >> ${LLVM_COMPILE_DEFINITIONS})
> >>  endfunction()
> >>
> >> @@ -137,6 +162,7 @@ macro(add_llvm_library name)
> >>    add_library( ${name} ${ALL_FILES} )
> >>    set_output_directory(${name} ${LLVM_RUNTIME_OUTPUT_INTDIR}
> >> ${LLVM_LIBRARY_OUTPUT_INTDIR})
> >>    set_property( GLOBAL APPEND PROPERTY LLVM_LIBS ${name} )
> >> +  llvm_update_compile_flags(${name} ${ALL_FILES})
> >>    add_dead_strip( ${name} )
> >>    if( LLVM_COMMON_DEPENDS )
> >>      add_dependencies( ${name} ${LLVM_COMMON_DEPENDS} )
> >> @@ -196,6 +222,7 @@ ${name} ignored.")
> >>      add_library( ${name} ${libkind} ${ALL_FILES} )
> >>      set_output_directory(${name} ${LLVM_RUNTIME_OUTPUT_INTDIR}
> >> ${LLVM_LIBRARY_OUTPUT_INTDIR})
> >>      set_target_properties( ${name} PROPERTIES PREFIX "" )
> >> +    llvm_update_compile_flags(${name} ${ALL_FILES})
> >>      add_dead_strip( ${name} )
> >>
> >>      if (LLVM_EXPORTED_SYMBOL_FILE)
> >> @@ -237,6 +264,7 @@ macro(add_llvm_executable name)
> >>    else()
> >>      add_executable(${name} ${ALL_FILES})
> >>    endif()
> >> +  llvm_update_compile_flags(${name} ${ALL_FILES})
> >>    add_dead_strip( ${name} )
> >>
> >>    if (LLVM_EXPORTED_SYMBOL_FILE)
> >> @@ -374,7 +402,7 @@ function(add_unittest test_suite test_na
> >>      set(LLVM_COMPILE_FLAGS "-Wno-variadic-macros")
> >>    endif ()
> >>
> >> -  set(LLVM_NO_RTTI ON)
> >> +  set(LLVM_REQUIRES_RTTI OFF)
> >>
> >>    add_llvm_executable(${test_name} ${ARGN})
> >>    set(outdir ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR})
> >> @@ -390,7 +418,6 @@ function(add_unittest test_suite test_na
> >>    if (NOT ${test_suite_folder} STREQUAL "NOTFOUND")
> >>      set_property(TARGET ${test_name} PROPERTY FOLDER
> >> "${test_suite_folder}")
> >>    endif ()
> >> -  llvm_update_compile_flags(${test_name})
> >>  endfunction()
> >>
> >>  # This function provides an automatic way to 'configure'-like generate
> a
> >> file
> >>
> >> Modified: llvm/trunk/cmake/modules/HandleLLVMOptions.cmake
> >> URL:
> >>
> http://llvm.org/viewvc/llvm-project/llvm/trunk/cmake/modules/HandleLLVMOptions.cmake?rev=200301&r1=200300&r2=200301&view=diff
> >>
> >>
> ==============================================================================
> >> --- llvm/trunk/cmake/modules/HandleLLVMOptions.cmake (original)
> >> +++ llvm/trunk/cmake/modules/HandleLLVMOptions.cmake Tue Jan 28 03:44:06
> >> 2014
> >> @@ -359,3 +359,11 @@ if(NOT CYGWIN AND NOT WIN32)
> >>      append("-ffunction-sections -fdata-sections" CMAKE_C_FLAGS
> >> CMAKE_CXX_FLAGS)
> >>    endif()
> >>  endif()
> >> +
> >> +if(MSVC)
> >> +  # Remove flags here, for exceptions and RTTI.
> >> +  # Each target property of source proerty should be responsible to
> >> control them.
> >> +  # CL.EXE complains to override flags like "/GR /GR-".
> >> +  string(REGEX REPLACE "(^| ) */EH[-cs]+ *( |$)" "\\1 \\2"
> >> CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
> >> +  string(REGEX REPLACE "(^| ) */GR-? *( |$)" "\\1 \\2" CMAKE_CXX_FLAGS
> >> "${CMAKE_CXX_FLAGS}")
> >> +endif()
> >>
> >>
> >> _______________________________________________
> >> llvm-commits mailing list
> >> llvm-commits at cs.uiuc.edu
> >> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
> >
> >
> >
> >
> > --
> > Alexey Samsonov, MSK
>



-- 
Alexey Samsonov, MSK
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20140131/4c2ced93/attachment.html>


More information about the llvm-commits mailing list