[SOLVED] Assembler error ‘illegal operands’ when compiling on RISC-V 64 computer lazarus / 64-FPC development ---------------------------------------------------------------------- yurets_z · 2024-06-29 10:32 I’m new to the topic of compiling the IDE from source and crosscompiling. I found it interesting to try porting a couple of my Lazarus GUI projects on RISC-V 64 SBC (VisionFive 2) operating under Debian OS. For that I used a cross compiled version of FPC 3.3.1 from trunk  (htt ps://downloads.freepascal.org/fpc/snapshot/trunk/riscv64-linux/fpc- 3.3.1.riscv64-linux.built.on.x86_64-linux.tar.gz) and Lazarus 3.4.0 source files. When trying to build the IDE (via “make clean all” ) I get the following output and assembler error in the mid of the process: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i (3104) Compiling formeditingintf.pas/home/user/Lazarus/components/ideintf/for meditingintf.pas(321,12) Note: (6058) Call to subroutine "function LeftFromDesignInfo(ADesignInfo:LongInt):System.SmallInt;" marked as inline is not inlined/home/user/Lazarus/components/ideintf/formediting intf.pas(323,11) Note: (6058) Call to subroutine "function TopFromDesignInfo(ADesignInfo:LongInt):System.SmallInt;" marked as inline is not inlined/home/user/Lazarus/components/ideintf/formediting intf.pas(337,26) Note: (6058) Call to subroutine "function LeftTopToDesignInfo(const ALeft:SmallInt;const ATop:SmallInt):System.LongInt;" marked as inline is not inlined/home/u ser/Lazarus/components/ideintf/formeditingintf.pas(150,43) Hint: (5024) Parameter "aForm" not used/home/user/Lazarus/components/ideintf/formeditingintf.pas(162,35) Hint: (5024) Parameter "AComponent" not used/home/user/Lazarus/components/ideintf/formeditingintf.pas(163,38) Hint: (5024) Parameter "Parent" not used/home/user/Lazarus/components/ideintf/formeditingintf.pas(163,63) Hint: (5024) Parameter "ChildClass" not used/home/user/Lazarus/components/ideintf/formeditingintf.pas(165,38) Hint: (5024) Parameter "AComponent" not used/home/user/Lazarus/components/ideintf/formeditingintf.pas(166,41) Hint: (5024) Parameter "AComponent" not used/home/user/Lazarus/components/ideintf/formeditingintf.pas(170,37) Hint: (5024) Parameter "aComponent" not used/home/user/Lazarus/components/ideintf/formeditingintf.pas(174,23) Hint: (5024) Parameter "Sender" not used/home/user/Lazarus/components/ideintf/formeditingintf.pas(174,50) Hint: (5024) Parameter "Key" not used/home/user/Lazarus/components/ideintf/formeditingintf.pas(174,66) Hint: (5024) Parameter "Shift" not used/home/user/Lazarus/components/ideintf/formeditingintf.pas(175,21) Hint: (5024) Parameter "Sender" not used/home/user/Lazarus/components/ideintf/formeditingintf.pas(175,48) Hint: (5024) Parameter "Key" not used/home/user/Lazarus/components/ideintf/formeditingintf.pas(175,64) Hint: (5024) Parameter "Shift" not used/home/user/Lazarus/components/ideintf/formeditingintf.pas(176,30) Hint: (5024) Parameter "Button" not used/home/user/Lazarus/components/ideintf/formeditingintf.pas(176,57) Hint: (5024) Parameter "Shift" not used/home/user/Lazarus/components/ideintf/formeditingintf.pas(176,82) Hint: (5024) Parameter "p" not used/home/user/Lazarus/components/ideintf/formeditingintf.pas(176,102) Hint: (5024) Parameter "Handled" not used/home/user/Lazarus/components/ideintf/formeditingintf.pas(177,30) Hint: (5024) Parameter "Shift" not used/home/user/Lazarus/components/ideintf/formeditingintf.pas(177,55) Hint: (5024) Parameter "p" not used/home/user/Lazarus/components/ideintf/formeditingintf.pas(177,75) Hint: (5024) Parameter "Handled" not used/home/user/Lazarus/components/ideintf/formeditingintf.pas(178,28) Hint: (5024) Parameter "Button" not used/home/user/Lazarus/components/ideintf/formeditingintf.pas(178,55) Hint: (5024) Parameter "Shift" not used/home/user/Lazarus/components/ideintf/formeditingintf.pas(178,80) Hint: (5024) Parameter "p" not used/home/user/Lazarus/components/ideintf/formeditingintf.pas(178,100) Hint: (5024) Parameter "Handled" not used/home/user/Lazarus/components/ideintf/formeditingintf.pas(179,45) Hint: (5024) Parameter "APersistent" not used/home/user/Lazarus/components/ideintf/formeditingintf.pas(179,80) Hint: (5024) Parameter "AIndex" not used(9009) Assembling formeditingintfunits/riscv64-linux/nogui/formeditingintf.s: Assembler messages:units/riscv64-linux/nogui/formeditingintf.s:4040: Error: illegal operands `lui ireg32,1'units/riscv64-linux/nogui/formeditingintf.s:4041: Error: illegal operands `addiw ireg32,ireg32,-1760'units/riscv64-linux/nogui/formeditingintf.s:4042: Error: illegal operands `add ireg33,x5,ireg32'units/riscv64-linux/nogui/formeditingintf.s:4043: Error: illegal operands `ld x5,0(ireg33)'units/riscv64-linux/nogui/formeditingintf.s:4127: Error: illegal operands `lui ireg32,1'units/riscv64-linux/nogui/formeditingintf.s:4128: Error: illegal operands `addiw ireg32,ireg32,-1760'units/riscv64-linux/nogui/formeditingintf.s:4129: Error: illegal operands `add ireg33,x5,ireg32'units/riscv64-linux/nogui/formeditingintf.s:4130: Error: illegal operands `ld x5,0(ireg33)'units/riscv64-linux/nogui/formeditingintf.s:4214: Error: illegal operands `lui ireg32,1'units/riscv64-linux/nogui/formeditingintf.s:4215: Error: illegal operands `addiw ireg32,ireg32,-1760'units/riscv64-linux/nogui/formeditingintf.s:4216: Error: illegal operands `add ireg33,x5,ireg32'units/riscv64-linux/nogui/formeditingintf.s:4217: Error: illegal operands `ld x5,0(ireg33)'units/riscv64-linux/nogui/formeditingintf.s:4231: Error: illegal operands `lui ireg32,1'units/riscv64-linux/nogui/formeditingintf.s:4232: Error: illegal operands `addiw ireg32,ireg32,-1456'units/riscv64-linux/nogui/formeditingintf.s:4233: Error: illegal operands `add ireg33,x5,ireg32'units/riscv64-linux/nogui/formeditingintf.s:4234: Error: illegal operands `ld x5,0(ireg33)'/home/user/Lazarus/components /ideintf/formeditingintf.pas(847) Error: (9007) Error while assembling exitcode 1/home/user/Lazarus/components/ideintf/formeditingintf.pas(847) Fatal: (10026) There were 2 errors compiling module, stoppingFatal: (1018) Compilation abortedmake[2]: *** [Makefile:3768: ideintf.ppu] Error 1make[2]: Leaving directory '/home/user/Lazarus/components/ideintf'make[1]: *** [Makefile:1912: lazbuildlclpackages] Error 2make[1]: Leaving directory '/home/user/Lazarus/components'make: *** [Makefile:3129: lazbuild] Error 2  I guess the complain is about ireg32 and ireg33 operands. Any ideas/suggestions about the reason and how that could be fixed? Kind regards, Yuriy ---------------------------------------------------------------------- jma_sp · 2025-07-24 19:51 Hello. Have you do any advance about it. I am also interested about having working FreePascal and Lazarus under Debian 64 bits and RISC-V ---------------------------------------------------------------------- marcov · 2025-07-25 08:06 ireg are register allocator failures, they are virtual registers that should have been replaced by real ones after register allocation. ---------------------------------------------------------------------- Laksen · 2025-07-25 09:49 Looks like thlcgriscv.g_intf_wrapper was never properly implemented ---------------------------------------------------------------------- yurets_z · 2025-10-06 22:45 Quote from: jma_sp on July 24, 2025, 09:51:53 pmHello. Have you do any advance about it. I am also interested about having working FreePascal and Lazarus under Debian 64 bits and RISC-V I've dropped the idea for a while. Google says the same problem was experienced at least by 1 more user https://lists.freepascal.org/fpc-devel/2024-August/045745.html ---------------------------------------------------------------------- Thaddy · 2025-10-07 11:25 1. the link is http, not https, so I would not download such a tarball. (Just in case you did not notice, or still studying for your Internet license) 2. Trunk is usually build from source. I am not aware that tarball is even legal. Please remove that link. 3. Build from source and remember 3.3.1 is a moving target and especially Risc-V has very regulat updates, 4. Never download from an insecure source, 5. Never download from an insecure source, 6. Never download from an insecure source. The other user is also stupid. ---------------------------------------------------------------------- Thaddy · 2025-10-07 11:31 Quote from: yurets_z on June 29, 2024, 12:32:18 pmWhen trying to build the IDE (via “make clean all” ) I get the following output and assembler error in the mid of the process: Use git clone or afterwards git pull Only after that try to build. git clone https://gitlab.com/freepascal.org/fpc/source.git fpc That is safe. The clone takes seconds, not hours. (note I am on fiber, may be minutes) ---------------------------------------------------------------------- ccrause · 2025-10-07 11:49 It seems that the use of (or at least compiling for) RISC-V is slowly picking up.  Other related bug reports: https://gitlab.com/freepascal.org/fpc/source/-/issues/40880 https://gitlab.com/freepascal.org/fpc/source/-/issues/41389 ---------------------------------------------------------------------- Thaddy · 2025-10-07 14:34 Quote from: ccrause on October 07, 2025, 01:49:49 pmIt seems that the use of (or at least compiling for) RISC-V is slowly picking up.  Other related bug reports: https://gitlab.com/freepascal.org/fpc/source/-/issues/40880 https://gitlab.com/freepascal.org/fpc/source/-/issues/41389 Not slowly for those that are interested. There are quite a lot of RISC-V based platforms available at super available prices. ---------------------------------------------------------------------- Marc · 2025-10-08 06:57 Quote from: Thaddy on October 07, 2025, 01:25:28 pm1. the link is http, not https, so I would not download such a tarball. (Just in case you did not notice, or still studying for your Internet license) 2. Trunk is usually build from source. I am not aware that tarball is even legal. Please remove that link. 3. Build from source and remember 3.3.1 is a moving target and especially Risc-V has very regulat updates, 4. Never download from an insecure source, 5. Never download from an insecure source, 6. Never download from an insecure source. The other user is also stupid. I'm not maintaining it, but IIRC downloads.freepascal.org is a valid source. And should point to the same location as the lazarus-ide counterpart, which currently isn't the case. Need to sort this out ---------------------------------------------------------------------- yurets_z · 2025-12-04 00:10 Quote from: Thaddy on October 07, 2025, 01:31:38 pmQuote from: yurets_z on June 29, 2024, 12:32:18 pmWhen trying to build the IDE (via “make clean all” ) I get the following output and assembler error in the mid of the process: Use git clone or afterwards git pull Only after that try to build. git clone https://gitlab.com/freepascal.org/fpc/source.git fpc That is safe. The clone takes seconds, not hours. (note I am on fiber, may be minutes) Thanks. Now a more specific question. Is there already a solution to have a working Lazarus/FPC on risc-v/linux platform ? Any suggestions where to download the installer? Or some workaround? ---------------------------------------------------------------------- Thaddy · 2025-12-04 06:48 I did not test Lazarus, but fpc itself is no problem. ---------------------------------------------------------------------- yurets_z · 2025-12-04 07:51 That sounds promising. Where can I find FPC installer for risc-v that just installs and work? ---------------------------------------------------------------------- PascalDragon · 2025-12-04 20:20 Quote from: yurets_z on December 04, 2025, 08:51:49 amWhere can I find FPC installer for risc-v that just installs and work? There is none, because RISC-V is currently only supported in the development version. ---------------------------------------------------------------------- yurets_z · 2025-12-04 20:30 That is strange. From the comments above I got feeling only me and a couple of other stupid newbies don't have it working as a charm.  (*sarcasm*) ---------------------------------------------------------------------- PascalDragon · 2025-12-04 20:50 Quote from: yurets_z on December 04, 2025, 09:30:24 pmFrom the comments above I got feeling only me and a couple of other stupid newbies don't have it working as a charm.  (*sarcasm*) Because if one knows how to build FPC it's no problem, however you explicitly asked for an installer and there is none. ---------------------------------------------------------------------- yurets_z · 2025-12-04 22:18 OK. Then its all clear. The request is solved. Time to go and ask elsewhere ---------------------------------------------------------------------- Thausand · 2025-12-05 07:22 Quote from: yurets_z on December 04, 2025, 11:18:23 pmOK. Then its all clear. The request is solved. Time to go and ask elsewhere Ask elsewhere for installer or have ask elsewhere for build FPC ? For installer that correct: is burden Linux distribution (there is exist debian linux package FPC and I have assume install x86 and risc is same then have copy-paste or have better use install script linux FPC that is store sourceforge). For build is make cross-compile compiler. It make generate risc exe (and package/unit) then can make archive and have use install script SourceForge). It not exist installer because risc target not finish (yet). ---------------------------------------------------------------------- yurets_z · 2026-01-14 22:54 Ask elsewhere for constructive assistance. ---------------------------------------------------------------------- Thausand · 2026-01-15 00:25 Quote from: yurets_z on January 14, 2026, 11:54:35 pmAsk elsewhere for constructive assistance. Yes, I have understand but that is no tell what is constructive assistance for you As write PascalDragon when ask for installer: There is no installer exists. It is no exists because FPC risc-v support not finish yet. When is risc-v for FPC finish then can make installer. Installer is for OS and FPC<>OS. Then is come play distribution/package maintainer and have make installer/package (or make script that other linux distribution is use and copy->pasta). If want FPC for risc now then have need for build fpc and use github (development) source. That is prerequisite and have learn how build FPC (that is require read and understand for build-faq and wiki. I think there not exist dedicate FPC wiki risc-v. If not know or no want know/learn how is build FPC then can use FPCUpDeluxe (Is exist version linux 64 bit riscv but then have no share what is exact target/host). When ask assistance then question need be clear. That is no reflect for be constructive or no constructive ---------------------------------------------------------------------- dbannon · 2026-01-15 11:55 yurets_z, you seem to be getting a bit of a roasting here, I have no idea why. Thaddy is always rude to people, please disregard him. Please don't judge us all by this exchange. It does seem you downloaded exactly what you should have, the readme for it says - QuoteThis snapshot fpc-3.3.1.riscv64-linux.built.on.x86_64-linux.tar.gz was generated 2026-01-14 12:14 on gcc421 using: make singlezipinstall OS_TARGET=linux CPU_TARGET=riscv64 SNAPSHOT=1 "BUILDFULLNATIVE=1 BUILDFULLNATIVE=1" PP=ppcx64 CROSSOPT="-XR/home/muller/sys-root/riscv64-linux  -Fl/home/muller/sys- root/riscv64-linux/usr/lib64/lp64d  -Fl=/home/muller/sys- root/riscv64-linux//usr/lib64/lp64d  -Fl/home/muller/sys- root/riscv64-linux/usr/lib64/lp64  -Xd -k--sysroot=/home/muller/sys- root/riscv64-linux -dXr_disabled" OPT="" I have never used those installers but looks like a good thing ! So, you are planning to run Lazarus (and FPC) on the SBC to do development work there ?  If so, you would be better to build a RISC-V64 compiler, not a cross compiler. Move it to the SBC and then run your Lazarus build there (if it has enough memory). Alternatively, if you plan to develop on your x86_64 box and cross compile then you don't need to build Lazarus with the cross compiler, just build (or install) a standard Lazarus and set a project mode to use your cross compiler from within the IDE. The IDE just does IDE stuff, it passes the compiling to what ever compiler is necessary. So, question, do you have an x86_64 compiler on your x86_64 machine ? The cross compiler you downloaded is not enough to build Lazarus. Davo ---------------------------------------------------------------------- yurets_z · 2026-10-06 22:57 Ok, thanks for the info. Seems like now there are available dedicated instructions for building risc-v compiler and cross compiler at the wiki https://wiki.freepascal.org/Instructions_for_building_the_Free_Pa scal_Compiler_for_the_RISC-V. The initial idea was to port and continue development of the existing project on a resource rich risc-v SBC and run the app on a low spec risc-v SBC. Maybe one day I will return to that idea. Maybe when risc-v compiler /IDE will be released. Currently have no more time and motivation to play with those compilers and  cross compilers. The project still happily runs on the old x86 netbook. ---------------------------------------------------------------------- Thaddy · 2026-10-07 07:29 On - Debian - linux there are only two dependencies to compile trunk: - buildessential (or its equivalent on non-debian derived nixes) - fp-compiler package (does just install the compiler + rtl: you do not need the full fpc package which installs a lot more and does not make sense if you are going to build from scratch) Both are in the distro's repositories. For riscv cross-compilation you need the riscv toolchain to be installed: e.g.:https://github.com/riscv-collab/riscv-gnu-toolchain I also use a clang install. (but gnu would also work, I guess) Debian (and derivatives): Code: Bash  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i sudo apt install buildessentialsudo apt install fp-compiler -yEquivalents for buildessential for suse and fedora: Code: Bash  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i sudo dnf groupinstall "Development Tools" "Development Libraries"sudo dnf install fp-compiler #check this! I seldom use a suse or fedora There are no prebuilds for this. It involves some work, but quite easy work, even for beginners.