mirror of
https://github.com/llvm-mirror/libcxx.git
synced 2025-10-23 18:38:30 +08:00
Attempt to fix stdint/cstdint modules try 2
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@287690 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -45,7 +45,13 @@ module std [system] {
|
|||||||
// <stddef.h>'s __need_* macros require textual inclusion.
|
// <stddef.h>'s __need_* macros require textual inclusion.
|
||||||
textual header "stddef.h"
|
textual header "stddef.h"
|
||||||
}
|
}
|
||||||
// FIXME: <stdint.h> is missing.
|
module stdint_h {
|
||||||
|
header "stdint.h"
|
||||||
|
export *
|
||||||
|
// FIXME: This module only exists on OS X and for some reason the
|
||||||
|
// wildcard above doesn't export it.
|
||||||
|
export Darwin.C.stdint
|
||||||
|
}
|
||||||
module stdio_h {
|
module stdio_h {
|
||||||
// <stdio.h>'s __need_* macros require textual inclusion.
|
// <stdio.h>'s __need_* macros require textual inclusion.
|
||||||
textual header "stdio.h"
|
textual header "stdio.h"
|
||||||
@@ -158,6 +164,7 @@ module std [system] {
|
|||||||
}
|
}
|
||||||
module cstdint {
|
module cstdint {
|
||||||
header "cstdint"
|
header "cstdint"
|
||||||
|
export depr.stdint_h
|
||||||
export *
|
export *
|
||||||
}
|
}
|
||||||
module cstdio {
|
module cstdio {
|
||||||
|
21
test/libcxx/modules/cinttypes_exports.sh.cpp
Normal file
21
test/libcxx/modules/cinttypes_exports.sh.cpp
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
//===----------------------------------------------------------------------===//
|
||||||
|
//
|
||||||
|
// The LLVM Compiler Infrastructure
|
||||||
|
//
|
||||||
|
// This file is dual licensed under the MIT and the University of Illinois Open
|
||||||
|
// Source Licenses. See LICENSE.TXT for details.
|
||||||
|
//
|
||||||
|
//===----------------------------------------------------------------------===//
|
||||||
|
|
||||||
|
// REQUIRES: modules-support
|
||||||
|
|
||||||
|
// Test that <cinttypes> re-exports <cstdint>
|
||||||
|
|
||||||
|
// RUN: %build_module
|
||||||
|
|
||||||
|
#include <cinttypes>
|
||||||
|
|
||||||
|
int main() {
|
||||||
|
int8_t x; ((void)x);
|
||||||
|
std::int8_t y; ((void)y);
|
||||||
|
}
|
21
test/libcxx/modules/cstdint_exports.sh.cpp
Normal file
21
test/libcxx/modules/cstdint_exports.sh.cpp
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
//===----------------------------------------------------------------------===//
|
||||||
|
//
|
||||||
|
// The LLVM Compiler Infrastructure
|
||||||
|
//
|
||||||
|
// This file is dual licensed under the MIT and the University of Illinois Open
|
||||||
|
// Source Licenses. See LICENSE.TXT for details.
|
||||||
|
//
|
||||||
|
//===----------------------------------------------------------------------===//
|
||||||
|
|
||||||
|
// REQUIRES: modules-support
|
||||||
|
|
||||||
|
// Test that <cstdint> re-exports <stdint.h>
|
||||||
|
|
||||||
|
// RUN: %build_module
|
||||||
|
|
||||||
|
#include <cstdint>
|
||||||
|
|
||||||
|
int main() {
|
||||||
|
int8_t x; ((void)x);
|
||||||
|
std::int8_t y; ((void)y);
|
||||||
|
}
|
20
test/libcxx/modules/inttypes_h_exports.sh.cpp
Normal file
20
test/libcxx/modules/inttypes_h_exports.sh.cpp
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
//===----------------------------------------------------------------------===//
|
||||||
|
//
|
||||||
|
// The LLVM Compiler Infrastructure
|
||||||
|
//
|
||||||
|
// This file is dual licensed under the MIT and the University of Illinois Open
|
||||||
|
// Source Licenses. See LICENSE.TXT for details.
|
||||||
|
//
|
||||||
|
//===----------------------------------------------------------------------===//
|
||||||
|
|
||||||
|
// REQUIRES: modules-support
|
||||||
|
|
||||||
|
// Test that intypes.h re-exports stdint.h
|
||||||
|
|
||||||
|
// RUN: %build_module
|
||||||
|
|
||||||
|
#include <inttypes.h>
|
||||||
|
|
||||||
|
int main() {
|
||||||
|
int8_t x; ((void)x);
|
||||||
|
}
|
20
test/libcxx/modules/stdint_h_exports.sh.cpp
Normal file
20
test/libcxx/modules/stdint_h_exports.sh.cpp
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
//===----------------------------------------------------------------------===//
|
||||||
|
//
|
||||||
|
// The LLVM Compiler Infrastructure
|
||||||
|
//
|
||||||
|
// This file is dual licensed under the MIT and the University of Illinois Open
|
||||||
|
// Source Licenses. See LICENSE.TXT for details.
|
||||||
|
//
|
||||||
|
//===----------------------------------------------------------------------===//
|
||||||
|
|
||||||
|
// REQUIRES: modules-support
|
||||||
|
|
||||||
|
// Test that int8_t and the like are exported from stdint.h not inttypes.h
|
||||||
|
|
||||||
|
// RUN: %build_module
|
||||||
|
|
||||||
|
#include <stdint.h>
|
||||||
|
|
||||||
|
int main() {
|
||||||
|
int8_t x; ((void)x);
|
||||||
|
}
|
@@ -65,7 +65,8 @@ class Configuration(object):
|
|||||||
self.cxx_library_root = None
|
self.cxx_library_root = None
|
||||||
self.cxx_runtime_root = None
|
self.cxx_runtime_root = None
|
||||||
self.abi_library_root = None
|
self.abi_library_root = None
|
||||||
self.module_cache_path = None
|
self.enable_modules = False
|
||||||
|
self.modules_flags = None
|
||||||
self.env = {}
|
self.env = {}
|
||||||
self.use_target = False
|
self.use_target = False
|
||||||
self.use_system_cxx_lib = False
|
self.use_system_cxx_lib = False
|
||||||
@@ -725,9 +726,12 @@ class Configuration(object):
|
|||||||
self.cxx.compile_flags += ['-O0']
|
self.cxx.compile_flags += ['-O0']
|
||||||
|
|
||||||
def configure_modules(self):
|
def configure_modules(self):
|
||||||
supports_modules = self.cxx.hasCompileFlag('-fmodules')
|
modules_flags = ['-fmodules']
|
||||||
enable_modules = self.get_lit_bool('enable_modules', False)
|
if platform.system() != 'Darwin':
|
||||||
if enable_modules and not supports_modules:
|
modules_flags += ['-Xclang', '-fmodules-local-submodule-visibility']
|
||||||
|
supports_modules = self.cxx.hasCompileFlag(modules_flags)
|
||||||
|
self.enable_modules = self.get_lit_bool('enable_modules', False)
|
||||||
|
if self.enable_modules and not supports_modules:
|
||||||
self.lit_config.fatal(
|
self.lit_config.fatal(
|
||||||
'-fmodules is enabled but not supported by the compiler')
|
'-fmodules is enabled but not supported by the compiler')
|
||||||
if not supports_modules:
|
if not supports_modules:
|
||||||
@@ -739,11 +743,11 @@ class Configuration(object):
|
|||||||
if os.path.isdir(module_cache):
|
if os.path.isdir(module_cache):
|
||||||
shutil.rmtree(module_cache)
|
shutil.rmtree(module_cache)
|
||||||
os.makedirs(module_cache)
|
os.makedirs(module_cache)
|
||||||
self.module_cache_path = module_cache
|
self.modules_flags = modules_flags + \
|
||||||
if enable_modules:
|
['-fmodules-cache-path=' + module_cache]
|
||||||
|
if self.enable_modules:
|
||||||
self.config.available_features.add('-fmodules')
|
self.config.available_features.add('-fmodules')
|
||||||
self.cxx.compile_flags += ['-fmodules',
|
self.cxx.compile_flags += self.modules_flags
|
||||||
'-fmodules-cache-path=' + module_cache]
|
|
||||||
|
|
||||||
def configure_substitutions(self):
|
def configure_substitutions(self):
|
||||||
sub = self.config.substitutions
|
sub = self.config.substitutions
|
||||||
@@ -759,12 +763,6 @@ class Configuration(object):
|
|||||||
sub.append(('%link_flags', link_flags_str))
|
sub.append(('%link_flags', link_flags_str))
|
||||||
sub.append(('%all_flags', all_flags))
|
sub.append(('%all_flags', all_flags))
|
||||||
|
|
||||||
module_flags = None
|
|
||||||
if not self.module_cache_path is None:
|
|
||||||
module_flags = '-fmodules -fmodules-cache-path=' \
|
|
||||||
+ self.module_cache_path + ' '
|
|
||||||
|
|
||||||
|
|
||||||
# Add compile and link shortcuts
|
# Add compile and link shortcuts
|
||||||
compile_str = (self.cxx.path + ' -o %t.o %s -c ' + flags_str
|
compile_str = (self.cxx.path + ' -o %t.o %s -c ' + flags_str
|
||||||
+ compile_flags_str)
|
+ compile_flags_str)
|
||||||
@@ -774,8 +772,11 @@ class Configuration(object):
|
|||||||
build_str = self.cxx.path + ' -o %t.exe %s ' + all_flags
|
build_str = self.cxx.path + ' -o %t.exe %s ' + all_flags
|
||||||
sub.append(('%compile', compile_str))
|
sub.append(('%compile', compile_str))
|
||||||
sub.append(('%link', link_str))
|
sub.append(('%link', link_str))
|
||||||
if not module_flags is None:
|
if self.enable_modules:
|
||||||
sub.append(('%build_module', build_str + ' ' + module_flags))
|
sub.append(('%build_module', build_str))
|
||||||
|
elif self.modules_flags is not None:
|
||||||
|
modules_str = ' '.join(self.modules_flags) + ' '
|
||||||
|
sub.append(('%build_module', build_str + ' ' + modules_str))
|
||||||
sub.append(('%build', build_str))
|
sub.append(('%build', build_str))
|
||||||
# Configure exec prefix substitutions.
|
# Configure exec prefix substitutions.
|
||||||
exec_env_str = 'env ' if len(self.env) != 0 else ''
|
exec_env_str = 'env ' if len(self.env) != 0 else ''
|
||||||
@@ -788,7 +789,7 @@ class Configuration(object):
|
|||||||
sub.append(('%exec', exec_str))
|
sub.append(('%exec', exec_str))
|
||||||
# Configure run shortcut
|
# Configure run shortcut
|
||||||
sub.append(('%run', exec_str + ' %t.exe'))
|
sub.append(('%run', exec_str + ' %t.exe'))
|
||||||
# Configure not program substitions
|
# Configure not program substitutions
|
||||||
not_py = os.path.join(self.libcxx_src_root, 'utils', 'not', 'not.py')
|
not_py = os.path.join(self.libcxx_src_root, 'utils', 'not', 'not.py')
|
||||||
not_str = '%s %s' % (sys.executable, not_py)
|
not_str = '%s %s' % (sys.executable, not_py)
|
||||||
sub.append(('not', not_str))
|
sub.append(('not', not_str))
|
||||||
|
Reference in New Issue
Block a user