Recent

Author Topic: [SOLVED] how to get {$LINKLIB libgte.a} in to the linker script?  (Read 1461 times)

Key-Real

  • Sr. Member
  • ****
  • Posts: 372
I have some libraries like
libgte.a
my executable should be linked against.
so i do in my program
{$LINKLIB libgte.a}

I'm at the writing linker script stage.

how to get the name of this lib in my t_ps1.pas in class(TExternalLinker)?
« Last Edit: July 20, 2024, 10:24:58 am by Key-Real »

ccrause

  • Hero Member
  • *****
  • Posts: 970
Re: how to get {$LINKLIB libgte.a} in to the linker script?
« Reply #1 on: July 19, 2024, 05:43:37 pm »
One option (untested) is to add the static library name with AddStaticLibrary('libname.a'); early in the WriteResponseFile method in your t_ps1.pas file.

Key-Real

  • Sr. Member
  • ****
  • Posts: 372
Re: how to get {$LINKLIB libgte.a} in to the linker script?
« Reply #2 on: July 19, 2024, 05:46:13 pm »
If I tell {$L mylib.a}

it cames to the linker as ObjectFiles.GetFirst

I can live with it :)

so how to get:

-Fl/usr/lib32/

to the linker?

MarkMLl

  • Hero Member
  • *****
  • Posts: 7997
Re: how to get {$LINKLIB libgte.a} in to the linker script?
« Reply #3 on: July 19, 2024, 06:07:03 pm »
I don't know whether this is in any way helpful, but a few months ago I came across this https://forum.lazarus.freepascal.org/index.php/topic,66610.msg510910.html#msg510910 very old thread which says

Quote
In a nutshell:
{$LinkLib LIBNAME} --> you need the LIBNAME.a file
{$Link LIBNAME} --> you need the LIBNAME.o file

I decided that was useful enough as a guideline to add as a comment to some of my existing code in a couple of places. If it is wildly wide of the mark my apologies for adding noise to your thread (I did a bit of work on the MIPS target very early on when it had degenerated into two separate projects, it's improved a lot since then byt I've never had appropriate hardware on which to run it).

MarkMLl
MT+86 & Turbo Pascal v1 on CCP/M-86, multitasking with LAN & graphics in 128Kb.
Logitech, TopSpeed & FTL Modula-2 on bare metal (Z80, '286 protected mode).
Pet hate: people who boast about the size and sophistication of their computer.
GitHub repositories: https://github.com/MarkMLl?tab=repositories

TRon

  • Hero Member
  • *****
  • Posts: 3618
Re: how to get {$LINKLIB libgte.a} in to the linker script?
« Reply #4 on: July 19, 2024, 06:25:11 pm »
@key-real:
what toolchain are you using ?

I am assuming gnu target mipsel-none-elf together with its binutils.

(external) linker support is present in the compiler what I do not know if the existing mipsel target (already) added support for that (I assume it does/did). In case the latter then you can follow its lead.

This tagline is powered by AI

nickysn

  • New Member
  • *
  • Posts: 27
Re: how to get {$LINKLIB libgte.a} in to the linker script?
« Reply #5 on: July 19, 2024, 06:26:56 pm »
If I tell {$L mylib.a}

it cames to the linker as ObjectFiles.GetFirst

Well, looking at the TLinker object, there's also SharedLibFiles and StaticLibFiles. They are declared right after ObjectFiles. Don't one of these contain what you need?

MarkMLl

  • Hero Member
  • *****
  • Posts: 7997
Re: how to get {$LINKLIB libgte.a} in to the linker script?
« Reply #6 on: July 19, 2024, 06:57:20 pm »
(external) linker support is present in the compiler what I do not know if the existing mipsel target (already) added support for that (I assume it does/did). In case the latter then you can follow its lead.

Once MIPS was floated into the mainstream- somewhere around 2.7.1- I definitely had both mipsel and mipseb running on emulated target boards using (I think) Qemu (we had a couple of SGI machines, but I can't remember whether I ever got a recognisable OS running on one of them).

There was no toolchain weirdness that I recall, the bottom of https://wiki.freepascal.org/Native_MIPS_Systems shows that I was able to build a runnable compiler, but apparently some code generation tests were still failing so a full self-build did not work (I might have seen that fixed later).

MarkMLl
MT+86 & Turbo Pascal v1 on CCP/M-86, multitasking with LAN & graphics in 128Kb.
Logitech, TopSpeed & FTL Modula-2 on bare metal (Z80, '286 protected mode).
Pet hate: people who boast about the size and sophistication of their computer.
GitHub repositories: https://github.com/MarkMLl?tab=repositories

Key-Real

  • Sr. Member
  • ****
  • Posts: 372
Re: how to get {$LINKLIB libgte.a} in to the linker script?
« Reply #7 on: July 19, 2024, 07:02:38 pm »
ok I pass

Code: Pascal  [Select][+][-]
  1. ./compiler/ppcrossmipsel test.pas -O- -Fu./rtl/ps1 -Fu./rtl/inc -Fu./rtl/objpas -Tps1 -Cfnone -Fu./psy-q-sdk/bindings -Fl./psy-q-sdk/lib -a -XP/usr/local/mipsel-unknown-elf/bin/mipsel-unknown-elf-

I got the -Fl string by
Code: Pascal  [Select][+][-]
  1. HPath:= TCmdStrListItem(LibrarySearchPath.First);

everything links, but the compiler tells me:
Code: Pascal  [Select][+][-]
  1. ree Pascal Compiler version 3.3.1 [2024/07/19] for mipsel
  2. Copyright (c) 1993-2024 by Florian Klaempfl and others
  3. Target OS: PlayStation 1 for MIPSEL
  4. Compiling test.pas
  5. Assembling program
  6. Warning: Object libgte.a not found, Linking may fail !
  7. Warning: Object libapi.a not found, Linking may fail !
  8.  

ideas?

nickysn

  • New Member
  • *
  • Posts: 27
Re: how to get {$LINKLIB libgte.a} in to the linker script?
« Reply #8 on: July 19, 2024, 07:09:04 pm »
Yes. Find the warning in errore.msg, look at its identifier (hint: it's "exec_w_libfile_not_found"), then search the compiler sources for this identifier, to see all places where this message is generated.

nickysn

  • New Member
  • *
  • Posts: 27
Re: how to get {$LINKLIB libgte.a} in to the linker script?
« Reply #9 on: July 19, 2024, 07:11:36 pm »
Sorry, it's actually "exec_w_objfile_not_found", not "exec_w_libfile_not_found".

Key-Real

  • Sr. Member
  • ****
  • Posts: 372
Re: how to get {$LINKLIB libgte.a} in to the linker script?
« Reply #10 on: July 19, 2024, 07:15:18 pm »
btw:

how to catch the
-a
compiler option?

Key-Real

  • Sr. Member
  • ****
  • Posts: 372
Re: how to get {$LINKLIB libgte.a} in to the linker script?
« Reply #11 on: July 19, 2024, 10:27:46 pm »
Code: Pascal  [Select][+][-]
  1.  
  2.  found:=FindFile(s,exepath,false,foundfile);
  3.  if not(cs_link_nolink in current_settings.globalswitches) and (not found) then
  4.          Message1(exec_w_objfile_not_found,s);
  5.  


he search in the exe path :(

but I specify -Fl./path/

now what?

ccrause

  • Hero Member
  • *****
  • Posts: 970
Re: how to get {$LINKLIB libgte.a} in to the linker script?
« Reply #12 on: July 19, 2024, 11:16:12 pm »
I have some libraries like
libgte.a
my executable should be linked against.
so i do in my program
{$LINKLIB libgte.a}

I'm at the writing linker script stage.

how to get the name of this lib in my t_ps1.pas in class(TExternalLinker)?

After reading the other messages in this discussion I believe I misunderstood your original question. Your t_ps1.pas implementation of TLinkerPS1.WriteScriptFile seems incomplete when compared against the equivalent method WriteResponseFile of t_linux.pas or t_embed.pas.  You probably need to write ObjectFiles to the INPUT section, and StaticLibFiles to the GROUP section of the linker response file.

 

TinyPortal © 2005-2018