I made llvm-openmp and applied the patch to libexec/ld.so and ran make install. I got the following result from make test of llvm-openmp:
-- Testing: 305 tests, 8 workers -- Testing: 0.. 10.. 20.. 30.. 40.. 50.. 60.. 70.. 80.. 90.. ******************** Unsupported Tests (18): libomp :: affinity/disabled.c libomp :: affinity/format/affinity_values.c libomp :: affinity/format/nested.c libomp :: affinity/format/proc_bind.c libomp :: affinity/kmp-affinity-reset.c libomp :: affinity/kmp-affinity.c libomp :: affinity/kmp-hw-subset.c libomp :: affinity/omp-places-invalid-syntax.c libomp :: affinity/omp-places.c libomp :: affinity/redetect.c libomp :: affinity/root-threads-affinity.c libomp :: affinity/teams-affinity.c libomp :: env/kmp_aff_disable_hwloc.c libomp :: ompt/misc/api_calls_from_other_thread.cpp libomp :: ompt/misc/api_calls_places.c libomp :: tasking/hidden_helper_task/affinity.cpp libomp :: tasking/hidden_helper_task/gtid.cpp libomp :: teams/teams.c Testing Time: 61.00s Total Discovered Tests: 305 Unsupported: 18 (5.90%) Passed : 287 (94.10%) ok asou@ -- ASOU Masato On Sat, Dec 7, 2024 at 8:06 AM Alexander Bluhm <alexander.bl...@gmx.net> wrote: > > On Thu, Dec 05, 2024 at 02:15:28PM +0100, Alexander Bluhm wrote: > > On Thu, Dec 05, 2024 at 10:01:42AM +0900, ASOU Masato wrote: > > > Ok, I will make devel/llvm-lit. > > > > Attached is a llvm-openmp that uses llvm-lit as test dependency. > > > > Unfortunately some tests are failing. > > > > Total Discovered Tests: 305 > > Unsupported: 18 (5.90%) > > Passed : 246 (80.66%) > > Failed : 41 (13.44%) > > > > Nevertheless I want to get some of these ports commited and debug > > problems in tree. llvm-lit passes all self tests. > > Most of the tests fail as our ld.so does not call the destructors. > Patch below decrements object refcount so callbacks from dynamic > loader to the openmp destructors work. As the order of the thread > teardown callbacks are different from linux I need some patches in > kmp_runtime.cpp to avoid crashes. > > Not sure if all may patches are correct, but OpenMP tests pass now. > > bluhm > > Index: libexec/ld.so/library_subr.c > =================================================================== > RCS file: /mount/openbsd/cvs/src/libexec/ld.so/library_subr.c,v > diff -u -p -r1.55 library_subr.c > --- libexec/ld.so/library_subr.c 27 Apr 2023 12:27:56 -0000 1.55 > +++ libexec/ld.so/library_subr.c 6 Dec 2024 20:28:11 -0000 > @@ -533,6 +533,17 @@ _dl_link_child(elf_object_t *dep, elf_ob > } > > void > +_dl_unlink_children(void) > +{ > + elf_object_t *node; > + > + for (node = _dl_objects; node != NULL; node = node->next) { > + if (node->refcount > 0) > + _dl_child_refcnt_decrement(node); > + } > +} > + > +void > object_vec_grow(struct object_vector *vec, int more) > { > vec->alloc += more; > Index: libexec/ld.so/loader.c > =================================================================== > RCS file: /mount/openbsd/cvs/src/libexec/ld.so/loader.c,v > diff -u -p -r1.223 loader.c > --- libexec/ld.so/loader.c 22 Jan 2024 02:08:31 -0000 1.223 > +++ libexec/ld.so/loader.c 6 Dec 2024 20:25:07 -0000 > @@ -202,6 +202,7 @@ _dl_dtors(void) > > /* ORDER? */ > _dl_unload_dlopen(); > + _dl_unlink_children(); > > DL_DEB(("doing dtors\n")); > > Index: libexec/ld.so/resolve.h > =================================================================== > RCS file: /mount/openbsd/cvs/src/libexec/ld.so/resolve.h,v > diff -u -p -r1.108 resolve.h > --- libexec/ld.so/resolve.h 21 May 2024 05:00:47 -0000 1.108 > +++ libexec/ld.so/resolve.h 6 Dec 2024 20:23:31 -0000 > @@ -318,6 +318,7 @@ int _dl_load_dep_libs(elf_object_t *obje > int _dl_rtld(elf_object_t *object); > void _dl_call_init(elf_object_t *object); > void _dl_link_child(elf_object_t *dep, elf_object_t *p); > +void _dl_unlink_children(void); > void _dl_link_grpsym(elf_object_t *object); > void _dl_cache_grpsym_list_setup(elf_object_t *_object); > void _dl_link_grpref(elf_object_t *load_group, elf_object_t *load_object);