[fpc-devel] SUBARCH's revisited, need some help for installing packages in a SUBARCH directory

Michael Ring mail at michael-ring.org
Sun Jun 9 16:11:55 CEST 2024


Hi!

Christo has done some magic on the esp32 targets and together we are 
currently trying to make everything available in an as consistent as 
possible way.

One thing that is very necessary from my point of view is that we 
properly support SUBARCH's when building rtl and packages as there are 
linker errors when an incompatible rtl is used for linking.

We never finished discussions on arm and avr targets, perhaps now is a 
good time to finalize the discussions and to apply the results to the 
esp32 targets as a start.

Until now we resorted to manually specify INSTALL_UNITDIR on 
installation but when the problem is properly addressed then also 
fpc.cfg can be changed accordingly to include the required directories 
in the search paths and things should work out of the box for every 
developer that wishes to build a cross-compiler from source.

I have now made this (kind of) work but I am still a bit unshure where 
the absolute best place is to make my changes and yes, there's a very 
crude hack involved....


While changes to make SUBARCH directories for RTL are pretty 
straightforward things look different for packages because they use 
fpmake and the switch from Makefiles to fpmake seems to cause issues 
that are hard to understand/debug for me....

The whole thing currently only works with this crude hack in the 
Makefile in the packages directory, at that point INSTALL_BASEDIR is not 
yet defined so I need to build the path to the proper location manually:


@@ -14,6 +14,14 @@ fpcdir=..

  [prerules]
  # Translate INSTALL_UNITDIR to fpmake's --unitinstalldir parameter
+ifndef INSTALL_UNITDIR
+ifeq ($(CPU_OS_TARGET),xtensa-freertos)
+INSTALL_UNITDIR=$(INSTALL_PREFIX)/lib/fpc/$(FPC_VERSION)/units/$(TARGETSUFFIX)/$(SUBARCH)
+endif
+ifeq ($(CPU_OS_TARGET),riscv32-freertos)
+INSTALL_UNITDIR=$(INSTALL_PREFIX)/lib/fpc/$(FPC_VERSION)/units/$(TARGETSUFFIX)/$(SUBARCH)
+endif
+endif
  ifdef INSTALL_UNITDIR
  FPMAKE_INSTALL_OPT+=--unitinstalldir=$(INSTALL_UNITDIR)
  endif

to get this:

./fpmake install --localunitdir=.. --os=freertos --cpu=riscv32 -o 
-Cprv32imc -o -Tfreertos -o -Priscv32 -o -XPriscv32-freertos- -o -Ur -o 
-Xs -o -O2 -o -n -o -driscv32 -o -dRELEASE 
--compiler=/Users/tgdrimi9/devel/fpc-esp32/compiler/ppcrossrv32 -bu -scp 
--prefix=/Users/tgdrimi9/devel/fpc-esp32/test 
--baseinstalldir=/Users/tgdrimi9/devel/fpc-esp32/test/lib/fpc/3.3.1 
--unitinstalldir=/Users/tgdrimi9/devel/fpc-esp32/test/lib/fpc/3.3.1/units/riscv32-freertos/rv32imc

for some reason unknown to me the following code (some lines deeper in 
the Makefiles) does not work, the unitinstalldir is not set when fpmake 
is called...

  ifndef INSTALL_UNITDIR
+ifeq ($(CPU_OS_TARGET),xtensa-freertos)
+INSTALL_UNITDIR:=$(INSTALL_BASEDIR)/units/$(TARGETSUFFIX)/$(SUBARCH)
+ifdef INSTALL_FPCPACKAGE
+ifdef PACKAGE_NAME
+INSTALL_UNITDIR:=$(INSTALL_UNITDIR)/$(PACKAGE_NAME)
+FPMAKE_INSTALL_OPT+=--unitinstalldir=$(INSTALL_UNITDIR)
+endif
+endif
+endif
+endif
+ifndef INSTALL_UNITDIR
+ifeq ($(CPU_OS_TARGET),riscv32-freertos)
  INSTALL_UNITDIR:=$(INSTALL_BASEDIR)/units/$(TARGETSUFFIX)/$(SUBARCH)
  ifdef INSTALL_FPCPACKAGE
  ifdef PACKAGE_NAME
  INSTALL_UNITDIR:=$(INSTALL_UNITDIR)/$(PACKAGE_NAME)

besides this there is another issue, the units are not put in their 
subdirectories, they are all put in the 
lib/fpc/3.3.1/units/riscv32-freertos/rv32imc directory.


Any help apprechiated, let me know when you need more info,


Michael



More information about the fpc-devel mailing list