From 5fe6f5c8cd620c8f9777a9f37098cc8ccf4e1b5e Mon Sep 17 00:00:00 2001 From: Philip Cho Date: Tue, 6 Feb 2018 15:40:23 -0800 Subject: [PATCH] Saner defaults in create_shared() * Disable Link-Time Optimization (LTO) by default, as it greatly increases compilation time * On UNIX-like systems, use /bin/sh for shell if SHELL environment is not set --- python/treelite/contrib/clang.py | 4 ++-- python/treelite/contrib/gcc.py | 4 ++-- python/treelite/contrib/util.py | 4 +++- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/python/treelite/contrib/clang.py b/python/treelite/contrib/clang.py index a0d11d16..b96457a8 100644 --- a/python/treelite/contrib/clang.py +++ b/python/treelite/contrib/clang.py @@ -29,12 +29,12 @@ def _obj_ext(): def _obj_cmd(source, options): obj_ext = _obj_ext() - return 'clang -c -O3 -o {} {} -fPIC -std=c99 -flto {}'\ + return 'clang -c -O3 -o {} {} -fPIC -std=c99 {}'\ .format(source + obj_ext, source + '.c', ' '.join(options)) def _lib_cmd(sources, target, lib_ext, options): obj_ext = _obj_ext() - return 'clang -shared -O3 -o {} {} -std=c99 -flto {}'\ + return 'clang -shared -O3 -o {} {} -std=c99 {}'\ .format(target + lib_ext, ' '.join([x['name'] + obj_ext for x in sources]), ' '.join(options)) diff --git a/python/treelite/contrib/gcc.py b/python/treelite/contrib/gcc.py index 8d222794..7a600d22 100644 --- a/python/treelite/contrib/gcc.py +++ b/python/treelite/contrib/gcc.py @@ -14,12 +14,12 @@ def _obj_ext(): def _obj_cmd(source, options): obj_ext = _obj_ext() - return 'gcc -c -O3 -o {} {} -fPIC -std=c99 -flto -fopenmp {}'\ + return 'gcc -c -O3 -o {} {} -fPIC -std=c99 -fopenmp {}'\ .format(source + obj_ext, source + '.c', ' '.join(options)) def _lib_cmd(sources, target, lib_ext, options): obj_ext = _obj_ext() - return 'gcc -shared -O3 -o {} {} -std=c99 -flto -fopenmp {}'\ + return 'gcc -shared -O3 -o {} {} -std=c99 -fopenmp {}'\ .format(target + lib_ext, ' '.join([x['name'] + obj_ext for x in sources]), ' '.join(options)) diff --git a/python/treelite/contrib/util.py b/python/treelite/contrib/util.py index e19e07f3..b0a45e46 100644 --- a/python/treelite/contrib/util.py +++ b/python/treelite/contrib/util.py @@ -14,8 +14,10 @@ def _is_windows(): def _shell(): if _is_windows(): return 'cmd.exe' - else: + elif 'SHELL' in os.environ: return os.environ['SHELL'] + else: + return '/bin/sh' # use POSIX-compliant shell if SHELL is not set def _libext(): if _platform == 'darwin':