I’m teaching programming using pascal for high school students and something come out of my curiosity.
I want to make a simple pascal source code batch compiler to compile my students’ source code files. But I want to restrict the source code from using RTL units, let’s say math.
program test;
uses math;
begin
writeln(logn(2,2));
end.
The logn is a function from math unit, so naturally if I remove the uses math line, the fpc compiler will show error message after compiling above code.
When I looked into the /etc/fpc.cfg file, the RTL units are included to the unit paths.
# searchpath for units and other system dependent things
-Fu/usr/lib/fpc/$fpcversion/units/$fpctarget
-Fu/usr/lib/fpc/$fpcversion/units/$fpctarget/*
-Fu/usr/lib/fpc/$fpcversion/units/$fpctarget/rtl
#-Fu~/fpc/packages/base/*/units/;~/fpc/fcl/units/;~/fpc/rtl/units/
But after I commented all those lines, the RTL units are still linked. As my last resort I have tried removing the rtl /usr/lib/fpc/2.4.0/units/x86_64-linux/rtl directory, but strangely the source code could still be compiled.
Any suggestion or did I miss any step?
FPC contains some compiled-in default units pathes (you can disable those and the loading of all configuration files by passing
-nto the compiler). Nevertheless, the compiled-in pathes do not explain why programs still compile when you delete/usr/lib/fpc/2.4.0/units/x86_64-linux/rtl. To narrow this done, compile with-vaand examine the output. The lines starting withPPU Loadingshow you where the compiler gets the units.