View Issue Details

IDProjectCategoryView StatusLast Update
0038987FPCCompilerpublic2021-06-12 20:45
ReporterAlfred Assigned ToFlorian  
Status resolvedResolutionfixed 
Product Version3.3.1 
Fixed in Version3.3.1 
Summary0038987: Linker not found with Android NDK >= 22
DescriptionStarting with Android NDK 22, the GNU binutils are depreciated. And will be removed.
As a first consequence, the standard linker ld[.exe] is not available anymore when using the LVVM tools. Only ld.bfd[.exe] is available.
Some changes in t-android.pas are needed to accommodate for this change. See included patch as a proposal. It should be backwards compatible for older NDK versions.
Please review.
Additional Information
TagsNo tags attached.
Fixed in Revision49498
Attached Files



2021-06-11 08:29


t-android.diff (962 bytes)   
Index: compiler/systems/t_android.pas
--- compiler/systems/t_android.pas	(revision 49492)
+++ compiler/systems/t_android.pas	(working copy)
@@ -436,14 +436,16 @@
   if IsSharedLib then
-  binstr:=FindUtil(utilsprefix+BinStr);
   { We should use BFD version of LD, since GOLD version does not support INSERT command in linker scripts }
-  if binstr <> '' then begin
-    { Checking if ld.bfd exists }
-    s:=ChangeFileExt(binstr, '.bfd' + source_info.exeext);
+  s:=utilsprefix+binstr+'.bfd';
+  if (source_info.exeext<>'') then
+    s:=s+source_info.exeext;
+  s:=FindUtil(s);
     if FileExists(s, True) then
-      binstr:=s;
-  end;
+    binstr:=s
+  else
+    // fallback to ld for very old or custom binutils
+    binstr:=FindUtil(utilsprefix+BinStr);
t-android.diff (962 bytes)   
androidlinker.JPG (104,406 bytes)   
androidlinker.JPG (104,406 bytes)   


2021-06-11 09:00

reporter   ~0131252

Also from
The deprecated <NDK>/platforms and <NDK>/sysroot directories have been removed. These directories were merged and relocated into the toolchain during r19. The location of these contents should not be relevant to anyone, including build systems, since the toolchain handles them implicitly. If you are using a build system that hasn't adapted to the changes introduced in NDK r19, file a bug with your build system maintainer. See the Build System Maintainers Guide for information on using the NDK in your own build system.
It would perhaps also be a possibility to use clang as linker. As stated above, it will set the correct library path for the selected API-level. This could make linking a bit easier.
Example: aarch64-linux-android30-clang hello.o -o
This sets the API to 30. And sets the correct search directories.
Drawback: FPC needs an extra compiler option for Android to set the desired API-level.


2021-06-11 20:50

administrator   ~0131264

I thought ld.bfd is also a GNU LD variant?


2021-06-12 01:53

reporter   ~0131266

Reference Android "Build System Maintainers Guide"


2021-06-12 05:46

reporter   ~0131267

Sure its all GNU. But this report is only about the missing ld, that causes ld.bfd not found error. The patch allows for ld.bfd to be found in the absence of ld itself.
If the GNU tools are definitely removed, more changes will be needed. But that is a future concern.


2021-06-12 20:45

administrator   ~0131274

Thanks, applied.

Issue History

Date Modified Username Field Change
2021-06-11 08:29 Alfred New Issue
2021-06-11 08:29 Alfred File Added: t-android.diff
2021-06-11 08:29 Alfred File Added: androidlinker.JPG
2021-06-11 09:00 Alfred Note Added: 0131252
2021-06-11 20:50 Florian Note Added: 0131264
2021-06-12 01:53 WayneSherman Note Added: 0131266
2021-06-12 05:46 Alfred Note Added: 0131267
2021-06-12 20:45 Florian Assigned To => Florian
2021-06-12 20:45 Florian Status new => resolved
2021-06-12 20:45 Florian Resolution open => fixed
2021-06-12 20:45 Florian Fixed in Version => 3.3.1
2021-06-12 20:45 Florian Fixed in Revision => 49498
2021-06-12 20:45 Florian FPCTarget => -
2021-06-12 20:45 Florian Note Added: 0131274