Skip to content

Commit

Permalink
Saner defaults in create_shared()
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
hcho3 committed Feb 12, 2018
1 parent 0b232c1 commit 5fe6f5c
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
4 changes: 2 additions & 2 deletions python/treelite/contrib/clang.py
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
4 changes: 2 additions & 2 deletions python/treelite/contrib/gcc.py
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
4 changes: 3 additions & 1 deletion python/treelite/contrib/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -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':
Expand Down

0 comments on commit 5fe6f5c

Please sign in to comment.