diff --git a/src/gnuwin32/MkRules.rules b/src/gnuwin32/MkRules.rules index f7c2752c489..362e91d37a3 100644 --- a/src/gnuwin32/MkRules.rules +++ b/src/gnuwin32/MkRules.rules @@ -156,7 +156,9 @@ ifndef USE_LLVM FLIBS=-lgfortran -lquadmath else FC=$(BINPREF)flang $(M_ARCH) - FLIBS=-lFortranRuntime -lFortranDecimal -lFortran_main -lc++ + ## Fortran_main is needed/available only in some builds of llvm/flang-new + LIBFM = $(or $(and $(wildcard $(EXT_LIBS)/lib/libFortran_main.a),-lFortran_main),) + FLIBS=-lFortranRuntime -lFortranDecimal $(LIBFM) -lc++ -lm endif LINKER=$(MAIN_LD) MAIN_LD=$(CC) diff --git a/src/gnuwin32/fixed/Makefile b/src/gnuwin32/fixed/Makefile index 290ae4194e5..131f100d1d5 100644 --- a/src/gnuwin32/fixed/Makefile +++ b/src/gnuwin32/fixed/Makefile @@ -46,6 +46,7 @@ fixetc: $(ETC) ../MkRules Makefile -e "s@NM_FILTER =@NM_FILTER = $(NM_FILTER)@" \ -e "s|LTO =|LTO = $(LTO)|" \ -e "s|LTO_OPT =|LTO_OPT = $(LTO_OPT)|" \ + -e "s|FLIBS =|FLIBS = $(FLIBS)|" \ etc/Makeconf > $(R_HOME)/etc$(R_ARCH)/Makeconf $(SED) -e "s+@BINDIR@+$(BINDIR)+" \ -e "s+@USE_LLVM@+$(USE_LLVM)+" \ diff --git a/src/gnuwin32/fixed/etc/Makeconf b/src/gnuwin32/fixed/etc/Makeconf index 7b04bd48f80..9e117c1e3b5 100644 --- a/src/gnuwin32/fixed/etc/Makeconf +++ b/src/gnuwin32/fixed/etc/Makeconf @@ -32,6 +32,7 @@ IMPDIR = bin M_ARCH = DT_ARCH = RC_ARCH = +FLIBS = # Used by packages tcltk and tkrplot TCL_HOME = $(R_HOME)/Tcl @@ -154,10 +155,8 @@ F_VISIBILITY = ## FC is the compiler used for all Fortran as from R 3.6.0 ifdef USE_LLVM FC = $(BINPREF)flang $(M_ARCH) - FLIBS = -lFortranRuntime -lFortranDecimal -lFortran_main -lc++ -lm else FC = $(BINPREF)gfortran $(M_ARCH) - FLIBS = -lgfortran -lm -lquadmath endif FCFLAGS = -O3 $(FDEBUGFLAG) @EOPTS@ $(LTO) ## additional libs needed when linking with $(FC), e.g. on some Oracle compilers