[fpc-devel] fnmatch (linux), where is the external

robert rozee rozee at mail.com
Tue Oct 17 13:17:18 CEST 2023


Date: Tue, 17 Oct 2023 09:32:16 +0200
From: Marco van de Voort <fpc at pascalprogramming.org>
> - without the patches you are reviewing it works all fine, suggesting a
> problem in those patches that somehow forces linking to the symbol
> without it being used.

to dispel any doubt, i've just created a new Linux Mint 21.2 (XFCE) 64-bit VM, using an ISO downloaded from the Mint website. after running all updates on the VM i then downloaded FPC and Lazarus .DEB install packages from:
https://sourceforge.net/projects/lazarus/files/Lazarus%20Linux%20i386%20DEB/Lazarus%202.2.6/
and installed the three packages (fpc-laz, fpc-src, lazarus-project) as per instructions. this gives a completely unpatch, unadulterated 64-bit Linux, running a completely unpatch, unadulterated FPC and Lazarus.

i next created a small GUI application that just displays a digital clock in a window. nothing fancy. this is the same 'GUI test application' i've been using throughout, although i created it anew to ensure there was no possibility of external contamination. i made NO changes to any of the Lazarus IDE settings, beyond selecting Tools->Options->Window->Show single button in TaskBar, and NO changes to the default project settings. the test program builds correctly, yielding a working GUI application that when run displays a small running digital clock display in a window.


after the above verification that everything was working, i then made a SINGLE change to the file fnmatch.inc located in /usr/share/fpcsrc/3.2.2/packages/gtk2/src/gtk+/gtk/ at line 37:

//// original declaration, start ////
function fnmatch(__pattern: char; __string: char;
__flags: gint): gint; cdecl; external gtklib;
//// original declaration, finish ////

//// altered declaration, start ////
function fnmatch(__pattern: char; __string: char;
__flags: gint): gint; cdecl; external; // gtklib;
//// altered declaration, finish ////

as you can see, the edit involved removing "gtklib" from after the word "external". i next rebuilt the compiler, RTL, etc using Fred vS's shell script:
#!/bin/sh
COMPILER=fpc
make clean
make all FPC=$COMPILER OPT="-Fl/usr/local/lib"
make FPC=$COMPILER install INSTALL_PREFIX=/usr/


NOW, the test application FAILS TO BUILD, with lazbuild reporting:

user at test:~/Pascal/Clock$ lazbuild ./project1.lpr
Hint: (lazarus) [RunTool] "/usr/bin/fpc" "-iWTOTP"
Hint: (lazarus) [RunTool] "/usr/bin/fpc" "-va" "compilertest.pas"
Hint: (lazarus) [RunTool] "/usr/bin/fpc" "-iWTOTP" "-Px86_64" "-Tlinux"
Hint: (lazarus) [RunTool] "/usr/bin/fpc" "-va" "compilertest.pas" "-Px86_64" "-Tlinux"
TProject.DoLoadStateFile Statefile not found: /home/user/Pascal/Clock/lib/x86_64-linux/project1.compiled
Hint: (11030) Start of reading config file /etc/fpc.cfg
Hint: (11031) End of reading config file /etc/fpc.cfg
Free Pascal Compiler version 3.2.2 [2023/10/17] for x86_64
Copyright (c) 1993-2021 by Florian Klaempfl and others
(1002) Target OS: Linux for x86-64
(3104) Compiling project1.lpr
(10001) PPU Loading /usr/share/lazarus/2.2.6/lcl/units/x86_64-linux/gtk2/gtk2int.ppu
(10011) PPU Source: gtk2int.pas not found
(10011) PPU Source: gtk2defines.inc not available
(10011) PPU Source: gtk2winapih.inc not available
(10011) PPU Source: gtk2lclintfh.inc not available
(10011) PPU Source: gtk2listslh.inc not available
(10011) PPU Source: gtk2widgetset.inc not available
(10011) PPU Source: gtk2winapi.inc not available
(10011) PPU Source: gtk2lclintf.inc not available
(10011) PPU Source: gtk2listsl.inc not available
(10028) Recompiling Gtk2Int, checksum changed for /usr/lib/fpc/3.2.2/units/x86_64-linux/gtk2/gtk2.ppu
/usr/share/lazarus/2.2.6/lcl/units/x86_64-linux/gtk2/gtk2int.ppu:gtk2int.pas(14,36) Fatal: (10022) Can't find unit Gtk2Int used by Interfaces
Fatal: (1018) Compilation aborted
Error: /usr/bin/ppcx64 returned an error exitcode
Error: (lazarus) Compile Project, Target: project1: stopped with exit code 1
Error: (lazbuild) failed compiling of project /home/user/Pascal/Clock/project1.lpi
user at test:~/Pascal/Clock$


reversing the edit, rebuilding the compiler, RTL, etc, and now when run lazbuild reports:

user at test:~/Pascal/Clock$ lazbuild ./project1.lpr
Hint: (lazarus) [RunTool] "/usr/bin/fpc" "-iWTOTP"
Hint: (lazarus) [RunTool] "/usr/bin/fpc" "-va" "compilertest.pas"
Hint: (lazarus) [RunTool] "/usr/bin/fpc" "-iWTOTP" "-Px86_64" "-Tlinux"
Hint: (lazarus) [RunTool] "/usr/bin/fpc" "-va" "compilertest.pas" "-Px86_64" "-Tlinux"
Hint: (11030) Start of reading config file /etc/fpc.cfg
Hint: (11031) End of reading config file /etc/fpc.cfg
Free Pascal Compiler version 3.2.2 [2023/10/17] for x86_64
Copyright (c) 1993-2021 by Florian Klaempfl and others
(1002) Target OS: Linux for x86-64
(3104) Compiling project1.lpr
(3104) Compiling unit1.pas
/home/user/Pascal/Clock/unit1.pas(18,27) Hint: (5024) Parameter "Sender" not used
/home/user/Pascal/Clock/unit1.pas(17,26) Hint: (5024) Parameter "Sender" not used
(9022) Compiling resource /home/user/Pascal/Clock/lib/x86_64-linux/project1.or
(9015) Linking /home/user/Pascal/Clock/project1
(1008) 92 lines compiled, 2.2 sec
(1022) 4 hint(s) issued
user at test:~/Pascal/Clock$

... and the result is a working GUI application. i can see no way the above results could exist if fnmatch were resolving to libc.so.6. the ONLY conclusion is that it is resolving to SOMEWHERE ELSE, and nobody seems to know where that somewhere else is.

would one of the FPC developers please care to duplicate the above tests?


cheers,
rob   :-)



More information about the fpc-devel mailing list