userland: start per-directory flags with userland/gcc

This commit is contained in:
Ciro Santilli 六四事件 法轮功
2019-03-13 00:00:01 +00:00
parent a85ca696c4
commit e32dcb85e9
4 changed files with 45 additions and 17 deletions

View File

@@ -17,6 +17,8 @@ class Main(common.BuildCliFunction):
Build our compiled userland examples. Build our compiled userland examples.
''' '''
) )
self.default_cstd = 'c11'
self.default_cxxstd = 'c++17'
self.add_argument( self.add_argument(
'--has-package', '--has-package',
action='append', action='append',
@@ -45,11 +47,12 @@ Default: build all examples that have their package dependencies met, e.g.:
in_path, in_path,
out_path, out_path,
ccflags, ccflags,
extra_deps=None,
link=True,
extra_objs=None,
std=None,
ccflags_after=None, ccflags_after=None,
cstd=None,
cxxstd=None,
extra_deps=None,
extra_objs=None,
link=True,
raise_on_failure=True, raise_on_failure=True,
thread_limiter=None, thread_limiter=None,
): ):
@@ -69,15 +72,19 @@ Default: build all examples that have their package dependencies met, e.g.:
do_compile = True do_compile = True
if in_ext == self.env['c_ext']: if in_ext == self.env['c_ext']:
cc = self.env['gcc'] cc = self.env['gcc']
if std is None: if cstd is None:
std = 'c11' std = self.default_cstd
else:
std = cstd
ccflags.extend([ ccflags.extend([
'-fopenmp', LF, '-fopenmp', LF,
]) ])
elif in_ext == self.env['cxx_ext']: elif in_ext == self.env['cxx_ext']:
cc = self.env['gxx'] cc = self.env['gxx']
if std is None: if cxxstd is None:
std = 'c++17' std = self.default_cxxstd
else:
std = cxxstd
else: else:
do_compile = False do_compile = False
if do_compile: if do_compile:
@@ -121,7 +128,6 @@ Default: build all examples that have their package dependencies met, e.g.:
'-Werror', LF, '-Werror', LF,
'-Wextra', LF, '-Wextra', LF,
'-Wno-unused-function', LF, '-Wno-unused-function', LF,
'-pedantic', LF,
'-ggdb3', LF, '-ggdb3', LF,
] ]
if self.env['static']: if self.env['static']:
@@ -183,6 +189,15 @@ Default: build all examples that have their package dependencies met, e.g.:
dirpath_relative_root dirpath_relative_root
) )
os.makedirs(out_dir, exist_ok=True) os.makedirs(out_dir, exist_ok=True)
ccflags_dir = ccflags.copy()
if dirpath_relative_root_components == ['gcc']:
cstd = 'gnu11'
cxxstd = 'gnu++17'
else:
cstd = self.default_cstd
cxxstd = self.default_cxxstd
# -pedantic complains even if we use -std=gnu11.
ccflags_dir.extend(['-pedantic', LF])
for in_filename in in_filenames: for in_filename in in_filenames:
in_path = os.path.join(path, in_filename) in_path = os.path.join(path, in_filename)
in_name, in_ext = os.path.splitext(in_filename) in_name, in_ext = os.path.splitext(in_filename)
@@ -191,7 +206,7 @@ Default: build all examples that have their package dependencies met, e.g.:
in_name + self.env['userland_build_ext'] in_name + self.env['userland_build_ext']
) )
pkg_key = in_name.split('_')[0] pkg_key = in_name.split('_')[0]
ccflags_file = ccflags.copy() ccflags_file = ccflags_dir.copy()
ccflags_after = [] ccflags_after = []
if pkg_key in pkgs: if pkg_key in pkgs:
if pkg_key not in has_packages: if pkg_key not in has_packages:
@@ -221,13 +236,15 @@ Default: build all examples that have their package dependencies met, e.g.:
thread = threading.Thread( thread = threading.Thread(
target=self._build_one, target=self._build_one,
kwargs={ kwargs={
'in_path':in_path, 'in_path': in_path,
'out_path':out_path, 'out_path': out_path,
'ccflags':ccflags_file, 'ccflags': ccflags_file,
'extra_objs':[common_obj], 'cstd': cstd,
'ccflags_after':ccflags_after, 'cxxstd': cxxstd,
'raise_on_failure':False, 'extra_objs': [common_obj],
'thread_limiter':thread_limiter, 'ccflags_after': ccflags_after,
'raise_on_failure': False,
'thread_limiter': thread_limiter,
} }
) )
thread.start() thread.start()

View File

@@ -0,0 +1,11 @@
/* Empty struct */
#include <assert.h>
#include <stdlib.h>
int main(void) {
struct s {};
struct s s0;
assert(sizeof(s0) == 0);
return EXIT_SUCCESS;
}