https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109452
Bug ID: 109452 Summary: omp_init_lock_with_hint() and omp_init_nest_lock_with_hint() are undefined Product: gcc Version: unknown Status: UNCONFIRMED Severity: normal Priority: P3 Component: libgomp Assignee: unassigned at gcc dot gnu.org Reporter: grg-webvisible+gcc.gnu.org at ai dot mit.edu CC: jakub at gcc dot gnu.org Target Milestone: --- omp_init_lock_with_hint() and omp_init_nest_lock_with_hint() appear to be declared but not defined: #include <omp.h> int main() { omp_lock_t lock; omp_init_lock_with_hint(&lock, omp_sync_hint_none); } compiled with: gcc -fopenmp main.cpp fails to link: In function `main': main.cpp:(.text+0x15): undefined reference to `omp_init_lock_with_hint' collect2: error: ld returned 1 exit status on v12.1.0: GNU C++17 (GCC) version 12.1.0 (x86_64-pc-linux-gnu) compiled by GNU C version 12.1.0, GMP version 6.2.1, MPFR version 4.1.0, MPC version 1.2.1, isl version isl-0.24-GMP Adding extra link options like -lgomp and -lpthread and -static does not help, nor does using a different omp_sync_hint (and none of these should in fact help). Also confirmed with v11.3.0 and v9.5.0. As a sanity check, the non-hint version works fine: #include <omp.h> int main() { omp_lock_t lock; omp_init_lock(&lock); } These results are consistent with the observation that all of the init...lock versions ({with and without hints} x {with and without nesting}) are declared in omp.h, while only the versions without hints are defined in gcc/libgomp/lock.c omp_init_lock_with_hint() and omp_init_nest_lock_with_hint() are part of the OpenMP 4.5 spec (Nov 2015), which is documented as being fully supported since gcc v6. The expedient solution of course would be to define in gcc/libgomp/lock.c the two init...with_hint functions to ignore the hint and call their corresponding unhinted init functions, e.g: void omp_init_lock_with_hint(omp_lock_t *lock, omp_sync_hint_t) { omp_init_lock(lock); } void omp_init_nest_lock_with_hint(omp_nest_lock_t *lock, omp_sync_hint_t) { omp_init_nest_lock(lock); } Combined with the appropriate alias magic in the various gcc/libgomp/config/*/lock.c files. It would be particularly impressive to actually use the hints to make the locks faster, but that's a larger project which probably deserves its own Bugz entry...