Commit 40d72743 authored by Nguyen, Thien Minh's avatar Nguyen, Thien Minh
Browse files

Ability to specify a linker in the qcor driver



On Summit, looks like the Clang-CSP was not able to link properly at the final linking phase. So just having an option to use the system compiler if needed.
Signed-off-by: Nguyen, Thien Minh's avatarThien Nguyen <nguyentm@ornl.gov>
parent edb54b54
......@@ -230,6 +230,8 @@ fatal_error_verbose = False
def main(argv=None):
compiler = '@CLANG_EXECUTABLE@'
# .o -> executable linker (use the Clang compiler by default)
obj_linker = compiler
verbose=False
if '--verbose' in sys.argv[1:]:
......@@ -273,6 +275,18 @@ def main(argv=None):
defaultFlags = ['-std=c++17', '-include', '@CMAKE_INSTALL_PREFIX@/include/qcor/qcor_lang_ext.hpp',
'-fplugin=@CMAKE_INSTALL_PREFIX@/clang-plugins/libqcor-syntax-handler@CMAKE_SHARED_LIBRARY_SUFFIX@']
if '-linker' in sys.argv[1:]:
# Ability to use another linker for the final compilation stage.
# In some (custom) systems, e.g., Summit, our compiled-from-source Clang-CSP compiler
# may not work properly. Hence, just allowing users to use the system-wide compiler.
idx = sys.argv.index('-linker')
linker_to_use = sys.argv[idx+1]
sys.argv.remove(linker_to_use)
sys.argv.remove('-linker')
if verbose:
info('Using ' + linker_to_use + ' linker')
obj_linker = linker_to_use
extra_flags = '@QCOR_EXTRA_COMPILER_FLAGS@'.split(' ')
if len(extra_flags):
defaultFlags += extra_flags
......@@ -912,7 +926,7 @@ def main(argv=None):
exit(1)
else:
# This is a .o file, so execute the link phase
commands = [compiler]
commands = [obj_linker]
if len(extra_flags):
commands += extra_flags
commands += ['-Wno-unused-command-line-argument', '-Wno-override-module'] + baseLibs + sys.argv[1:]
......@@ -920,7 +934,10 @@ def main(argv=None):
if verbose:
info('{}'.format(' '.join([c for c in commands])))
try:
result = subprocess.run(commands, check=True)
if obj_linker == compiler:
result = subprocess.run(commands, check=True)
else:
os.system('{}'.format(' '.join([c for c in commands])))
except subprocess.CalledProcessError as e:
print(e.output)
print(e.returncode)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment