FreeBSD 13.1 cprt0.o error lazarus / 36-Other ---------------------------------------------------------------------- d.ioannidis · 2023-01-17 13:47 Hi,   I can't build / compile any project for FreeBSD box 13.1-RELEASE-p3(64-bit). The error I'm getting is : 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 cprt0.o: .note.GNU-stack section implies executable stack ( see attached img ) Free Pascal ( 3.2.2 ) / Lazarus ( 2.2.4 ) installed using pkg. Any hint ? regards, ---------------------------------------------------------------------- Fred vS · 2023-01-17 15:02 Hello d.ioannidis. Did you try to run applications compiled with FreeBSD 11 on your FreeBSD 13 machine? For example, does this application run on your system? (just unzip and run "StrumPract" ) : https://github.com/fredvs/strumpract/releases/dow nload/3.4.0/StrumPract_3_4_0_freebsd_amd64.zip It was compiled with fpc 3.2.2. for FreeBSD 64 on a FreeBSD 11 system. Thanks. Fre;D ---------------------------------------------------------------------- sketch · 2023-01-17 15:56 FreeBSD uses ld.lld which is as drop-in replacement for GNU binutils BFD and gold linkers. But your error message shows ld.BFD which seems like it is using GNU binutils. I don't know why the FreeBSD linker would report BFD just because it's a drop-in replacement. And since it is in /usr/local/bin makes it seem it is using GNU binutils. Otherwise, it would be in /usr/bin. Anyway, the release of GNU binutils 2.39 added several new warnings to the linker. QuoteSince binutils 2.39, ld will print a warning if any stack section is executable, which is the default for stack sections on files without a .note.GNU-stack section.The warning Quotewarning: cprt0.o: missing .note.GNU-stack section implies executable stack is letting you know the program is being given an executable stack. Warning messages about the creation of an executable stack can be disabled with --no-warn-execstack and warnings about executable segments can be disabled --no-warn-rwx-segments. Also check if you are using the GNU linker or the FreeBSD linker. ---------------------------------------------------------------------- d.ioannidis · 2023-01-17 18:27 Hi,   @sketch   @Fred vS    apologies for my wrong post. I'm not familiar with BSD's.   Actually, I can build and run programs just fine . I was misled by the log message while linking  which started with "Error:" and the fact that I was testing FreeBSD and FPC in a slow VM ...   Sorry again for the noise ... regards, ---------------------------------------------------------------------- Fred vS · 2023-01-17 19:11 Quote from: d.ioannidis on January 17, 2023, 07:27:40 pmHi,   @sketch   @Fred vS    apologies for my wrong post. I'm not familiar with BSD's.   Actually, I can build and run programs just fine . I was misled by the log message while linking  which started with "Error:" and the fact that I was testing FreeBSD and FPC in a slow VM ...   Sorry again for the noise ... regards, Ha, nice you make it work. Also me sorry for the noise, I just tried the application compiled on FreeBSD 11 and fpc 3.2.2 on a FreeBSD 13 machine and it works out-of- the-box. By the way, if you are new to FreeBSD, you may consider to try GhostBSD, it has all needed for a nice desktop machine and install is very easy: https://ghostbsd.org/download But maybe you want use FreeBSD only for console apps like server, if so, also sorry for that noise. ---------------------------------------------------------------------- marcov · 2023-01-17 19:47 I reworked some FreeBSD support in post 3.2.2 fixes and trunk. BSDers are recommended to upgrade asap. To bootstrap, you need to make "ld.bfd" default (symlink to "ld"), and then bootstrap. After the bootstrap, the compiler will execute "ld.bfd" rather than "ld". llvm ld is not workable at this moment, it seems to have no error handling, and simply silently omit everything it doesn't understand. p.s. bootstrap experience might vary depending if you installed "COMPAT"systems while installing Freebsd or not. ---------------------------------------------------------------------- Fred vS · 2023-01-17 20:19 Quote from: marcov on January 17, 2023, 08:47:56 pmI reworked some FreeBSD support in post 3.2.2 fixes and trunk. BSDers are recommended to upgrade asap. To bootstrap, you need to make "ld.bfd" default (symlink to "ld"), and then bootstrap. After the bootstrap, the compiler will execute "ld.bfd" rather than "ld". llvm ld is not workable at this moment, it seems to have no error handling, and simply silently omit everything it doesn't understand. p.s. bootstrap experience might vary depending if you installed "COMPAT"systems while installing Freebsd or not. Ha, nice, thanks, I will try. To make fpc 3.2.2. work on my FreeBSD machine I had to change in /compiler/systems/t_bsd.pas, procedure TLinkerBSD.SetDefaultInfo : 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  if (target_info.system in (systems_openbsd+[system_x86_64_dragonfly]))  or  (target_info.system in (systems_freebsd+[system_x86_64_freebsd]))  // add this  then LdProgram:='ld.bfd'; And recompile fpc and then all was ok. ---------------------------------------------------------------------- marcov · 2023-01-18 15:22 Check you generated a real FreeBSD 13 binary (either file or elfdump -n). This is what the post 3.2.2 fixes aim to solve, creating Free BSD 12/13 native binaries. (depending on the ELF identifier in rtl/freebsd/cprt0 etc) ---------------------------------------------------------------------- Fred vS · 2023-01-18 22:45 Quote from: marcov on January 18, 2023, 04:22:30 pmCheck you generated a real FreeBSD 13 binary (either file or elfdump -n). This is what the post 3.2.2 fixes aim to solve, creating Free BSD 12/13 native binaries. (depending on the ELF identifier in rtl/freebsd/cprt0 etc) Hello Marco. Doing this of a binary file compiled with fpc official release 3.2.2 + my patch on a FreeBSD 13.1 system (last GhostBSD): 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 $ file strumpract gives this: Quotestrumpract: ELF 64-bit LSB executable, x86-64, version 1 (FreeBSD), dynamically linked, interpreter /usr/libexec/ld-elf.so.1, stripped elfdump -n strumpract gives nothing. How can I see if it was a real FreeBSD 13 binary? ---------------------------------------------------------------------- marcov · 2023-01-19 08:25 Probably the elfdump failure is a sign. -n dumps note sections, and the note sections changed in newer FreeBSD. So that is probably an older -compat binary. ---------------------------------------------------------------------- pelle · 2023-10-24 17:38 Being a bit new both to FreePascal and FreeBSD I am not sure what to do about this. The message I see (in FreeBSD 13.2) is only a warning, not an error,  and it seems as if the generated binary runs properly, at least for very simple test-programs. But it is annoying to get a warning every time, and it looks like it may turn into an error on future upgrade? Code: [Select]/usr/local/bin/ld.bfd: warning: /usr/local/lib/fpc/3.2.2/units/x86_64-freebsd/rtl/prt0.o: missing .note.GNU-stack section implies executable stack /usr/local/bin/ld.bfd: NOTE: This behaviour is deprecated and will be removed in a future version of the linker Should this perhaps be reported to someone that is building the official FreeBSD package? Is the only way for now to patch the fpc code and recompile it? What makes me a bit confused is that it seems like I already have ld.bfd, and that is the linker that should be used, right? ---------------------------------------------------------------------- AlexTP · 2023-10-24 18:37 What you can do: don't use BSD packaged FPC/Lazarus, but get fpcUpDeluxe and install the last git version (or last release version?) ---------------------------------------------------------------------- pelle · 2023-10-28 21:45 Quote from: AlexTP on October 24, 2023, 08:37:27 pmWhat you can do: don't use BSD packaged FPC/Lazarus, but get fpcUpDeluxe and install the last git version (or last release version?) OK. Thanks for the suggestion. Unfortunately I tried now with both with the trunk and stable versions, but I get the same linker warning with both (same as for the packaged version). ---------------------------------------------------------------------- marcov · 2024-02-20 14:52 cprt, dllprt and gprt now have non-xecutable stack note in trunk and fixes that silences the warning. Note that this only came out when you linked dynamically linked binaries.