Skip to content

Commit c0b39cf

Browse files
krystophnyclaude
andcommitted
fix: Use appropriate compilers for linking pure C/C++ programs
- Fix check_c_source_runs() to use C compiler (icx) instead of Fortran compiler (ifx) for linking - Fix check_cxx_source_runs() to use C++ compiler (icpx) instead of Fortran compiler for linking - Resolves "multiple definition of main" error with Intel Fortran compiler - Intel Fortran automatically links for_main.o which conflicts with C main() functions - This enables C/C++ compiler capability testing (e.g., OpenMP flag detection) to work correctly The previous approach of using Fortran compiler for linking pure C/C++ programs caused linker conflicts because Intel Fortran includes its own main entry point. Using the appropriate language compiler for pure language programs is the correct approach. Fixes test failures in check-c-source-runs and check-cxx-source-runs. Related to OpenMP metapackage C/C++ compiler capability detection. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
1 parent a454059 commit c0b39cf

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

src/fpm_compiler.F90

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1859,8 +1859,9 @@ logical function check_c_source_runs(self, input, compile_flags, link_flags) res
18591859
call self%compile_c(source,object,flags,logf,stat,dry_run=.false.)
18601860
if (stat/=0) return
18611861

1862-
!> Link
1863-
call self%link(exe,ldflags//" "//object,logf,stat)
1862+
!> Link using C compiler for pure C programs
1863+
call run(self%cc//" "//ldflags//" "//object//" -o "//exe, &
1864+
echo=self%echo, verbose=self%verbose, redirect=logf, exitstat=stat)
18641865
if (stat/=0) return
18651866

18661867
!> Run
@@ -1915,8 +1916,9 @@ logical function check_cxx_source_runs(self, input, compile_flags, link_flags) r
19151916
call self%compile_cpp(source,object,flags,logf,stat,dry_run=.false.)
19161917
if (stat/=0) return
19171918

1918-
!> Link
1919-
call self%link(exe,ldflags//" "//object,logf,stat)
1919+
!> Link using C++ compiler for pure C++ programs
1920+
call run(self%cxx//" "//ldflags//" "//object//" -o "//exe, &
1921+
echo=self%echo, verbose=self%verbose, redirect=logf, exitstat=stat)
19201922
if (stat/=0) return
19211923

19221924
!> Run

0 commit comments

Comments
 (0)