Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
[modules][cxxmodules] Improve the layering of our special modules.
There are three different kinds of header files in Core:
  * C headers - they can be included in C contexts
  * Config headers - they are supposed to be textually included in each
    TU.
  * No RTTI C++ headers - they can be built in non-rtti context which is
    needed for stage1 builds.

The rest of the headers in Core require rtti in order to be built, either
because they use typeinfo or exceptions.

This patch structures the ROOT's special modules in that way allowing
implicit module builds to be trigger from the right complation. For
example, we cannot (and should not) trigger build of C++ module when
compiling C code.
  • Loading branch information
vgvassilev committed Feb 17, 2018
commit f2f7075da5d78c98e9b34f8ae7dacea26f89c149
84 changes: 38 additions & 46 deletions build/unix/module.modulemap
Original file line number Diff line number Diff line change
@@ -1,57 +1,49 @@
// This can be used in C mode. It cannot go in ROOT_Type because ThreadLocalStorage.h
// uses kFALSE and kTRUE, which come from Rtypes.h causing a cycle.
// FIXME: This should be separated because it introduces header dependency
// libThread->libCore->libThread. We should figure out a way to implement it in
// a more reasonable way.
module ThreadLocalStorage [system] {
header "ThreadLocalStorage.h"
// This module contains header files from module Core which can be used in both
// C and C++ context.
module ROOT_Foundation_C [system] {
module "ThreadLocalStorage.h" { header "ThreadLocalStorage.h" export * }
module "strlcpy.h" { header "strlcpy.h" export * }
module "snprintf.h" { header "snprintf.h" export * }

export *
}
// These can be used in C mode.
module ROOT_Types [system] {
module "RtypesCore.h" { header "RtypesCore.h" export * }
module "ESTLType.h" { header "ESTLType.h" export * }
// FIXME: This module should contain only header files with types.
// The listed below headers are here because we want them to work in both
// -frtti and -fno-rtti environment. Move them into a separate module.
module "RStringView.h" { header "RStringView.h" export * }
module "Varargs.h" { header "Varargs.h" export * } // Old should revisit, either drop or delete.
module "TClassEdit.h" { header "TClassEdit.h" export * }
module "strlcpy.h" { header "strlcpy.h" export * }

// This module contains header files from module Core which are used as
// configuration for ROOT. They contain a lot of macro definitions which are
// supposed to be textually expanded in each TU.
module ROOT_Config [system] {
// These headers are supposed to be only textually expanded for each TU.
module "RVersion.h" { textual header "RVersion.h" export * }
module "RConfig.h" { textual header "RConfig.h" export * }
module "DllImport.h" { header "DllImport.h" export * } // Should merge in RConfig.h.
module "RConfigure.h" { textual header "RConfigure.h" export * }
module "RVersion.h" { textual header "RVersion.h" export * }
// This should go in RConfig.h as it defines macros.
// FIXME: There is little benefit in keeping DllImport as a separate header.
// The majority of its uses already include Rtypes.h which includes DllImport.
module "DllImport.h" { header "DllImport.h" export * }

export *
}

// This module is special, it contains headers which don't require rtti support
// to build (eg. don't use dynamic_cast or typeid). They are also needed when
// compiling rootcling with -fno-rtti. We have to keep them outside module ROOT
// to avoid -fno-rtti invocation to trigger building of entire module ROOT
// some of whose headers require -frtti.
// Rtypes.h however has an optional dependency on rtti unless one defines
// R__NO_INLINE_CLASSDEF. We therefore keep two versions of this module: One
// with rtti and one without rtti.
module ROOT_Core_Config_C [system] {
//requires cplusplus

exclude header "RtypesImp.h"
module "Rtypes.h" { header "Rtypes.h" export * }
module "TException.h" { header "TException.h" export * }
module "TGenericClassInfo.h" { header "TGenericClassInfo.h" export * }
module "TSchemaHelper.h" { header "TSchemaHelper.h" export * }
module "RootMetaSelection.h" { header "RootMetaSelection.h" export * }
module "snprintf.h" { header "snprintf.h" export * } // #included by Rtypes, could go away?
module "TIsAProxy.h" { header "TIsAProxy.h" export * }
module "TVirtualIsAProxy.h" { header "TVirtualIsAProxy.h" export * }

// Should we marked textual because of inclusion libcpp_string_view.h,
// using macros to set up the header file.
module "RWrap_libcpp_string_view.h" { textual header "RWrap_libcpp_string_view.h" export * }
// This module contains header files from module Core which do not need -frtti.
// They are mainly needed for ROOT stage1 build.
module ROOT_Foundation_Stage1_NoRTTI [system] {
module "RtypesCore.h" { header "RtypesCore.h" export * }
module "ESTLType.h" { header "ESTLType.h" export * }
module "RStringView.h" {
// RWrap_libcpp_string_view.h is meant to be included only by RStringView.h
textual header "RWrap_libcpp_string_view.h"
header "RStringView.h"
export *
}
// Varargs contains a lot of macros for supporting the obsolete va_args.
// FIXME: We may want to drop this when we reimplement all uses to use variadic
// templates.
module "Varargs.h" { header "Varargs.h" export * }
module "TClassEdit.h" { header "TClassEdit.h" export * }
module "TIsAProxy.h" { header "TIsAProxy.h" export * }
module "TVirtualIsAProxy.h" { header "TVirtualIsAProxy.h" export * }
module "TException.h" { header "TException.h" export * }

export *
export *
}

// Some frameworks include gl.h or gltypes.h (eg. Cocoa) and thus we cannot build
Expand Down
9 changes: 4 additions & 5 deletions cmake/modules/RootNewMacros.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -469,12 +469,11 @@ function (ROOT_CXXMODULES_APPEND_TO_MODULEMAP library library_headers)
endif()
endif(APPLE)

set(excluded_headers RConfig.h RVersion.h RtypesImp.h
Rtypes.h RtypesCore.h TClassEdit.h
set(excluded_headers RConfig.h RVersion.h RtypesImp.h TVersionCheck.h
RtypesCore.h TClassEdit.h
TIsAProxy.h TVirtualIsAProxy.h
DllImport.h TGenericClassInfo.h
TSchemaHelper.h ESTLType.h RStringView.h Varargs.h
RootMetaSelection.h libcpp_string_view.h
DllImport.h ESTLType.h RStringView.h Varargs.h
libcpp_string_view.h
RWrap_libcpp_string_view.h
ThreadLocalStorage.h
TBranchProxyTemplate.h TGLIncludes.h TGLWSIncludes.h
Expand Down
1 change: 1 addition & 0 deletions core/base/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ include_directories(${CMAKE_CURRENT_SOURCE_DIR}/res ${CMAKE_CURRENT_SOURCE_DIR}/

ROOT_GLOB_HEADERS(Base_dict_headers ${CMAKE_CURRENT_SOURCE_DIR}/inc/LinkDef?.h
${CMAKE_CURRENT_SOURCE_DIR}/inc/T*.h
${CMAKE_CURRENT_SOURCE_DIR}/inc/Rtypes.h
${CMAKE_CURRENT_SOURCE_DIR}/inc/GuiTypes.h
${CMAKE_CURRENT_SOURCE_DIR}/inc/MessageTypes.h
${CMAKE_CURRENT_SOURCE_DIR}/inc/KeySymbols.h
Expand Down
2 changes: 1 addition & 1 deletion core/thread/inc/ThreadLocalStorage.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
#include <stddef.h>

#ifdef __cplusplus
#include "Rtypes.h"
#include "RtypesCore.h"
#endif

#include <ROOT/RConfig.h>
Expand Down