Skip to content

Commit

Permalink
config: check for libatomic. Fixes #90.
Browse files Browse the repository at this point in the history
  • Loading branch information
mgates3 committed Dec 7, 2024
1 parent 8d59c13 commit b15ab92
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 0 deletions.
20 changes: 20 additions & 0 deletions config/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -784,6 +784,26 @@ def gpu_blas():
print_warn( 'No GPU BLAS library found' )
# end

#-------------------------------------------------------------------------------
def require_libatomic():
'''
Tests whether using `std::atomic` requires linking with `-latomic`
for 64-bit values, which is the case on some 32-bit systems.
'''
print_test( 'std::atomic links without -latomic' )
(rc, out, err) = compile_exe( 'config/require_libatomic.cc' )
print_result( 'x', rc )
if (rc != 0):
print_test( 'std::atomic requires -latomic' )
env = {'LIBS': '-latomic'}
(rc, out, err) = compile_exe( 'config/require_libatomic.cc', env )
print_result( 'x', rc )
if (rc == 0):
environ.merge( env )
else:
raise Error( 'cannot compile libatomic test' )
# end

#-------------------------------------------------------------------------------
def get_package( name, directories, repo_url, tar_url, tar_filename ):
'''
Expand Down
11 changes: 11 additions & 0 deletions config/require_libatomic.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#include <atomic>
#include <cstdint>

int main( int argc, char** argv )
{
std::atomic<std::int64_t> x = 0;
for (int i = 1; i < argc; ++i) {
++x;
}
return x;
}
1 change: 1 addition & 0 deletions configure.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ def main():
#config.prog_cxx_flag( '-Wmissing-declarations' )
#config.prog_cxx_flag( '-Wconversion' )
#config.prog_cxx_flag( '-Werror' )
config.require_libatomic()

config.openmp()

Expand Down

0 comments on commit b15ab92

Please sign in to comment.