Skip to content
This repository has been archived by the owner on Nov 11, 2024. It is now read-only.

Commit

Permalink
Only link object files in add_openmp_flags_if_available
Browse files Browse the repository at this point in the history
Restrict the OpenMP test to attempting to link files that
end in the compiler's object file extension as determined
by `ccompiler.obj_extension`.

The OpenMP test was yielding a false negative if the user had
set the environment variable `CFLAGS='-coverage'` to measure
code coverage with GCC. The error message was:

    /usr/bin/ld:objects/test_openmp.gcno: file format not
    recognized; treating as linker script
    /usr/bin/ld:objects/test_openmp.gcno:1: syntax error

When GCC is called with the `-coverage` option, it emits extra
data files, which should *not* be passed to the linker because
they are not object files.
  • Loading branch information
lpsinger committed Feb 8, 2018
1 parent 16db007 commit 4d48a6e
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
2 changes: 2 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ astropy-helpers Changelog

- Fix compatibility with setuptools 36.x and above. [#372]

- Fix false negative in add_openmp_flags_if_available when measuring code
coverage with gcc. [#374]

2.0.3 (2018-01-20)
------------------
Expand Down
2 changes: 1 addition & 1 deletion astropy_helpers/openmp_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ def add_openmp_flags_if_available(extension):

# Compile, link, and run test program
ccompiler.compile(['test_openmp.c'], output_dir='objects', extra_postargs=[compile_flag])
ccompiler.link_executable(glob.glob(os.path.join('objects', '*')), 'test_openmp', extra_postargs=[link_flag])
ccompiler.link_executable(glob.glob(os.path.join('objects', '*' + ccompiler.obj_extension)), 'test_openmp', extra_postargs=[link_flag])
output = subprocess.check_output('./test_openmp').decode(sys.stdout.encoding or 'utf-8').splitlines()

if 'nthreads=' in output[0]:
Expand Down

0 comments on commit 4d48a6e

Please sign in to comment.