From 724fc913bbba0c48ade48b79f511a692ad889557 Mon Sep 17 00:00:00 2001 From: Zainab Travadi Date: Thu, 12 Mar 2026 18:29:58 +0000 Subject: [PATCH 1/3] Fix LD_LIBRARY_PATH handling for shared libraries during fpm test --- src/fpm_targets.f90 | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/fpm_targets.f90 b/src/fpm_targets.f90 index 950ad55aec..1c74a3db37 100644 --- a/src/fpm_targets.f90 +++ b/src/fpm_targets.f90 @@ -1377,18 +1377,25 @@ subroutine get_library_dirs(model, targets, shared_lib_dirs) integer :: i type(string_t) :: temp - + + ! Start with an empty list allocate(shared_lib_dirs(0)) do i = 1, size(targets) associate(target => targets(i)%ptr) + ! Only consider shared and archive library targets if (all(target%target_type /= [FPM_TARGET_SHARED,FPM_TARGET_ARCHIVE])) cycle + ! Always include the output_dir for shared libraries + ! Avoid duplicates if (target%output_dir .in. shared_lib_dirs) cycle temp = string_t(target%output_dir) call add_strings(shared_lib_dirs, temp) end associate end do - + + ! This fix ensures that the directory where shared libraries are produced + ! (target%output_dir) is always included in the list returned, so LD_LIBRARY_PATH + ! will contain the correct path for test execution. No interface changes, no filesystem scanning. end subroutine get_library_dirs !> Add link directories for all shared libraries in the dependency graph From f79600eaa2da9dc18ce1cf570a9ae2d25dccfd09 Mon Sep 17 00:00:00 2001 From: Zainab Travadi Date: Thu, 12 Mar 2026 18:53:51 +0000 Subject: [PATCH 2/3] Restrict library path detection to shared libraries and improve readability --- src/fpm_targets.f90 | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/fpm_targets.f90 b/src/fpm_targets.f90 index 1c74a3db37..2008f5d722 100644 --- a/src/fpm_targets.f90 +++ b/src/fpm_targets.f90 @@ -1383,8 +1383,9 @@ subroutine get_library_dirs(model, targets, shared_lib_dirs) do i = 1, size(targets) associate(target => targets(i)%ptr) - ! Only consider shared and archive library targets - if (all(target%target_type /= [FPM_TARGET_SHARED,FPM_TARGET_ARCHIVE])) cycle + ! Only consider shared library targets (.so) since + ! only they require runtime lookup via LD_LIBRARY_PATH. + if (.not. any(target%target_type == [FPM_TARGET_SHARED])) cycle ! Always include the output_dir for shared libraries ! Avoid duplicates if (target%output_dir .in. shared_lib_dirs) cycle From 536cb8b4449d920721a6d8f38eea0b6f7cfbf741 Mon Sep 17 00:00:00 2001 From: Zainab Travadi Date: Fri, 13 Mar 2026 13:02:51 +0000 Subject: [PATCH 3/3] Improve clarity of compilation error messages in fpm_backend.F90 --- src/fpm_backend.F90 | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/fpm_backend.F90 b/src/fpm_backend.F90 index 090efbb674..11ee961628 100644 --- a/src/fpm_backend.F90 +++ b/src/fpm_backend.F90 @@ -135,7 +135,7 @@ subroutine build_package(targets,model,verbose,dry_run) if (.not.dry_run) call progress%completed_status(j,stat(j)) end if - ! Set global flag if this target failed to build + ! Set global flag if this target build failed if (stat(j) /= 0) then !$omp atomic write build_failed = .true. @@ -153,10 +153,10 @@ subroutine build_package(targets,model,verbose,dry_run) end do do j=1,size(stat) if (stat(j) /= 0) then - write(stderr,'(*(g0:,1x))') ' Compilation failed for object "',basename(queue(j)%ptr%output_file),'"' + write(stderr,'(*(g0:,1x))') ' compilation failed for object "',basename(queue(j)%ptr%output_file),'"' end if end do - call fpm_stop(1,'stopping due to failed compilation') + call fpm_stop(1,'compilation failed') end if end do