Skip to content

Commit e16f82e

Browse files
committed
Added a modulemap for libc
The Linux builds with enabled modules were failing because stdio.h wasn't provided by a module but textually included. This seemed to cause merging issues which caused the compilation to fail. This patch adds a modulemap for a few libc modules that seem to work without modification as modules inside ROOT. We had to remove a few 'extern "C"' because importing a module inside such a context isn't allowed.
1 parent 121286a commit e16f82e

File tree

8 files changed

+55
-7
lines changed

8 files changed

+55
-7
lines changed

CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,7 @@ if(cxxmodules)
192192
configure_file(${CMAKE_SOURCE_DIR}/build/unix/modulemap.overlay.yaml.in ${CMAKE_BINARY_DIR}/include/modulemap.overlay.yaml @ONLY)
193193

194194
configure_file(${CMAKE_SOURCE_DIR}/build/unix/stl.cppmap ${CMAKE_BINARY_DIR}/include/stl.cppmap)
195+
configure_file(${CMAKE_SOURCE_DIR}/build/unix/libc.modulemap ${CMAKE_BINARY_DIR}/include/libc.modulemap)
195196
endif()
196197

197198
# These vars are useful when we want to compile things without cxxmodules.

build/rmkdepend/mainroot.cxx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,10 @@
2727

2828
#include <string>
2929

30-
extern "C" {
3130
#if defined(__sun) && defined(__SUNPRO_CC)
3231
#include <signal.h>
3332
#endif
3433
#include "def.h"
35-
}
3634

3735
#ifndef WIN32
3836
#include <unistd.h>

build/unix/libc.modulemap

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
module "libc" {
2+
export *
3+
module "assert.h" {
4+
export *
5+
header "assert.h"
6+
}
7+
module "ctype.h" {
8+
export *
9+
header "ctype.h"
10+
}
11+
module "errno.h" {
12+
export *
13+
header "errno.h"
14+
}
15+
module "fenv.h" {
16+
export *
17+
header "fenv.h"
18+
}
19+
module "float.h" {
20+
export *
21+
header "float.h"
22+
}
23+
module "inttypes.h" {
24+
export *
25+
header "inttypes.h"
26+
}
27+
28+
module "xlocale.h" {
29+
export *
30+
header "xlocale.h"
31+
}
32+
module "math.h" {
33+
export *
34+
header "math.h"
35+
}
36+
module "stdio.h" {
37+
export *
38+
header "stdio.h"
39+
}
40+
}

build/unix/modulemap.overlay.yaml.in

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,13 @@
88
'external-contents': '@CMAKE_BINARY_DIR@/include/stl.cppmap'
99
}
1010
]
11+
},
12+
{ 'name': '/usr/include/', 'type': 'directory',
13+
'contents': [
14+
{ 'name': 'module.modulemap', 'type': 'file',
15+
'external-contents': '@CMAKE_BINARY_DIR@/include/libc.modulemap'
16+
}
17+
]
1118
}
1219
]
1320
}

graf2d/asimage/src/TASImage.cxx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,6 @@ ROOT tutorials: `$ROOTSYS/tutorials/image/`
9494
#else
9595
# include "Windows4root.h"
9696
#endif
97-
extern "C" {
9897
#ifndef WIN32
9998
#ifdef R__HAS_COCOA
10099
# define X_DISPLAY_MISSING 1
@@ -107,6 +106,7 @@ extern "C" {
107106
#endif
108107
# include <afterimage.h>
109108
# include <bmp.h>
109+
extern "C" {
110110
# include <draw.h>
111111
}
112112

graf2d/asimage/src/TASPaletteEditor.cxx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,16 +40,15 @@ It is called by a pull down menu item of TASImage.
4040
#include "Windows4root.h"
4141
#endif
4242

43-
extern "C" {
4443
#ifndef WIN32
4544
# include <afterbase.h>
4645
#else
4746
# include <win32/config.h>
4847
# include <win32/afterbase.h>
4948
#endif
5049
# include <afterimage.h>
50+
extern "C" {
5151
# include <bmp.h>
52-
5352
}
5453

5554

graf2d/asimage/src/TASPluginGS.cxx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ Allows to read PS/EPS/PDF files via GhostScript
3030
# define popen_flags "r"
3131
#endif
3232

33-
extern "C" {
3433
#ifndef WIN32
3534
# include <afterbase.h>
3635
#else
@@ -39,7 +38,6 @@ extern "C" {
3938
# define X_DISPLAY_MISSING 1
4039
#endif
4140
# include <import.h>
42-
}
4341

4442

4543
ClassImp(TASPluginGS)

math/unuran/CMakeLists.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,11 @@ endif()
5252
string(REPLACE -Wall "" CMAKE_C_FLAGS "${CMAKE_C_FLAGS}")
5353
if(${CMAKE_CXX_COMPILER_ID} MATCHES Clang)
5454
ROOT_ADD_C_FLAG(CMAKE_C_FLAGS -Wno-parentheses-equality)
55+
# unuran is including some modules from libc within extern-C.
56+
# This is disabling that clang is throwing an error when doing this.
57+
if(cxxmodules)
58+
ROOT_ADD_C_FLAG(CMAKE_C_FLAGS -Wno-module-import-in-extern-c)
59+
endif()
5560
endif()
5661

5762
include_directories(BEFORE ${UNR_UNTARDIR} ${UNR_UNTARDIR}/src ${UNR_UNTARDIR}/src/utils)

0 commit comments

Comments
 (0)