Discussion:
MacOS Mojave beta - crt1.o not installed to /usr/lib
(too old to reply)
Michael Ring
2018-07-01 20:18:41 UTC
Permalink
We've had this discussion (Jonas and me) a looong time ago (2013) with
MacOS Maverics....

In the past, when xcode commandline tools was installed it created a
link to crt1.10.5.o in /usr/lib.

It now seems that this is not done anymore (at least not on my
computer...) and as /usr/lib is write protected for root in newer
versions of MacOSX it is not that easy to create a link by hand.

The good news is that

clang -print-search-dirs

programs: =/Library/Developer/CommandLineTools/usr/bin
libraries: =/Library/Developer/CommandLineTools/usr/lib/clang/10.0.0

returns a libraries path that helps finding a valid crt1.(10.5).o file:

find /Library/Developer/CommandLineTools/ -name "crt1*"
/Library/Developer/CommandLineTools//SDKs/MacOSX.sdk/usr/lib/crt1.o
/Library/Developer/CommandLineTools//SDKs/MacOSX.sdk/usr/lib/crt1.10.5.o
/Library/Developer/CommandLineTools//SDKs/MacOSX.sdk/usr/lib/crt1.10.6.o

I managed to get a successful compile by doing this:

make clean buildbase CPU_TARGET=x86_64 INSTALL_PREFIX=$HOME/3.1.1
FPCOPT="-XR/Library/Developer/CommandLineTools//SDKs/MacOSX.sdk/"

and patching my /etc/fpc.cfg to include:

#ifdef cpui386
-XR/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/
-Fl/Library/Developer/CommandLineTools/usr/lib/clang/10.0.0
#endif
#ifdef cpux86_64
-XR/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/
-Fl/Library/Developer/CommandLineTools/usr/lib/clang/10.0.0
#endif


both actions were needed for a successful compile...


Is there a better way to make compiles work on Mojave?


Michael






_______________________________________________
fpc-devel maillist - fpc-***@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-deve
Jonas Maebe
2018-07-01 20:34:32 UTC
Permalink
Post by Michael Ring
make clean buildbase CPU_TARGET=x86_64 INSTALL_PREFIX=$HOME/3.1.1
FPCOPT="-XR/Library/Developer/CommandLineTools//SDKs/MacOSX.sdk/"
#ifdef cpui386
-XR/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/
-Fl/Library/Developer/CommandLineTools/usr/lib/clang/10.0.0
#endif
#ifdef cpux86_64
-XR/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/
-Fl/Library/Developer/CommandLineTools/usr/lib/clang/10.0.0
#endif
both actions were needed for a successful compile...
What errors do you get if you don't include the -Fl option?
Post by Michael Ring
Is there a better way to make compiles work on Mojave?
The -XR above seems to be the correct way to handle this change. We
could also hard code that search path in the compiler in addition to
/usr/lib


Jonas
_______________________________________________
fpc-devel maillist - fpc-***@lists.freepascal.org
http://list
Michael Ring
2018-07-01 20:52:00 UTC
Permalink
I only adjusted -Fl to match the current version installed, having a
wrong issue there did not change the build behaviour. The change
necessary was to include

-XR/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/

otherwise fpcmake will not compile.


Cross-Compiling did however not work, the makefile of fpcmake does seem
to support FPCOPT but somehow the parameter does not get forwarded to
the makefile:

/Library/Developer/CommandLineTools/usr/bin/make -C utils/fpcm bootstrap
FPC=/Users/ring/devel/fpc-arm/compiler/ppcrossarm
FPCFPMAKE=/Users/ring/devel/fpc-arm/compiler/ppc RELEASE=1 'OPT='

results in:

/Users/ring/devel/fpc-arm/compiler/ppc fpcmake.pp -n
-Fu/Users/ring/devel/fpc-arm/rtl/units/x86_64-darwin
-FU/Users/ring/devel/fpc-arm/utils/fpcm/units/x86_64-darwin
ld: file not found: /usr/lib/crt1.10.5.o
An error occurred while linking

I could make crosscompiling work by doing this (Use OPT instead of FPCOPT)

make clean buildbase CROSSINSTALL=1 OS_TARGET=embedded CPU_TARGET=arm
SUBARCH=$SUBARCH CROSSOPT="$CROSSOPT" BINUTILSPREFIX=arm-none-eabi-
OPT="-XR/Library/Developer/CommandLineTools//SDKs/MacOSX.sdk/"

I hope that hardcoding the path
/Library/Developer/CommandLineTools//SDKs/MacOSX.sdk/ in FPC will solve
this.....

Thank you,

Michael
Post by Jonas Maebe
Post by Michael Ring
make clean buildbase CPU_TARGET=x86_64 INSTALL_PREFIX=$HOME/3.1.1
FPCOPT="-XR/Library/Developer/CommandLineTools//SDKs/MacOSX.sdk/"
#ifdef cpui386
-XR/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/
-Fl/Library/Developer/CommandLineTools/usr/lib/clang/10.0.0
#endif
#ifdef cpux86_64
-XR/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/
-Fl/Library/Developer/CommandLineTools/usr/lib/clang/10.0.0
#endif
both actions were needed for a successful compile...
What errors do you get if you don't include the -Fl option?
Post by Michael Ring
Is there a better way to make compiles work on Mojave?
The -XR above seems to be the correct way to handle this change. We
could also hard code that search path in the compiler in addition to
/usr/lib
Jonas
_______________________________________________
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel
_______________________________________________
fpc-devel maillist - fpc-***@lists.freepascal.org
http://lists.freepasc
Michael Ring
2018-07-01 21:31:17 UTC
Permalink
This small patch helped me to get rid of the need to define
-XR/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/ in /etc/fpc.cfg


It would be greet to have something similar in the upcoming 3.0.5
release (and of course in trunk) so that also building lazarus with a
3.0.5 compiler works (It currently fails without the entry in fpc.cfg)


Michael


Index: compiler/systems/t_bsd.pas
===================================================================
--- compiler/systems/t_bsd.pas    (revision 39358)
+++ compiler/systems/t_bsd.pas    (working copy)
@@ -248,6 +248,9 @@
             system_i386_darwin,
             system_x86_64_darwin:
               begin
+                { 10.14 and later: crt1.o }
+                if CompareVersionStrings(MacOSXVersionMin,'10.14')>=0 then
+                  exit('crt1.so');
                 { 10.8 and later: no crt1.* }
                 if CompareVersionStrings(MacOSXVersionMin,'10.8')>=0 then
                   exit('');
@@ -377,7 +380,10 @@
   if startupfile<>'' then
     begin
      if not librarysearchpath.FindFile(startupfile,false,result) then
-       result:='/usr/lib/'+startupfile
+       if sysutils.fileexists('/usr/lib/'+startupfile) then
+         result:='/usr/lib/'+startupfile
+       else if
sysutils.fileexists('/Library/Developer/CommandLineTools//SDKs/MacOSX.sdk/usr/lib/'+startupfile)
then
+
result:='/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/lib/'+startupfile
     end
   else
     result:='';
Post by Michael Ring
I only adjusted -Fl to match the current version installed, having a
wrong issue there did not change the build behaviour. The change
necessary was to include
-XR/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/
otherwise fpcmake will not compile.
Cross-Compiling did however not work, the makefile of fpcmake does
seem to support FPCOPT but somehow the parameter does not get
/Library/Developer/CommandLineTools/usr/bin/make -C utils/fpcm
bootstrap FPC=/Users/ring/devel/fpc-arm/compiler/ppcrossarm
FPCFPMAKE=/Users/ring/devel/fpc-arm/compiler/ppc RELEASE=1 'OPT='
/Users/ring/devel/fpc-arm/compiler/ppc fpcmake.pp -n
-Fu/Users/ring/devel/fpc-arm/rtl/units/x86_64-darwin
-FU/Users/ring/devel/fpc-arm/utils/fpcm/units/x86_64-darwin
ld: file not found: /usr/lib/crt1.10.5.o
An error occurred while linking
I could make crosscompiling work by doing this (Use OPT instead of FPCOPT)
make clean buildbase CROSSINSTALL=1 OS_TARGET=embedded CPU_TARGET=arm
SUBARCH=$SUBARCH CROSSOPT="$CROSSOPT" BINUTILSPREFIX=arm-none-eabi-
OPT="-XR/Library/Developer/CommandLineTools//SDKs/MacOSX.sdk/"
I hope that hardcoding the path
/Library/Developer/CommandLineTools//SDKs/MacOSX.sdk/ in FPC will
solve this.....
Thank you,
Michael
Post by Jonas Maebe
Post by Michael Ring
make clean buildbase CPU_TARGET=x86_64 INSTALL_PREFIX=$HOME/3.1.1
FPCOPT="-XR/Library/Developer/CommandLineTools//SDKs/MacOSX.sdk/"
#ifdef cpui386
-XR/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/
-Fl/Library/Developer/CommandLineTools/usr/lib/clang/10.0.0
#endif
#ifdef cpux86_64
-XR/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/
-Fl/Library/Developer/CommandLineTools/usr/lib/clang/10.0.0
#endif
both actions were needed for a successful compile...
What errors do you get if you don't include the -Fl option?
Post by Michael Ring
Is there a better way to make compiles work on Mojave?
The -XR above seems to be the correct way to handle this change. We
could also hard code that search path in the compiler in addition to
/usr/lib
Jonas
_______________________________________________
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel
_______________________________________________
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel
_______________________________________________
fpc-devel maillist - fpc-***@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel
Michael Ring
2018-07-01 21:53:25 UTC
Permalink
Seems I misunderstood the meaning of "MacOSXVersionMin", it is set to
10.5 on my MacOS Mojave !!??!!

So the patch gets even more simple:

Index: compiler/systems/t_bsd.pas
===================================================================
--- compiler/systems/t_bsd.pas    (revision 39358)
+++ compiler/systems/t_bsd.pas    (working copy)
@@ -377,7 +377,10 @@
   if startupfile<>'' then
     begin
      if not librarysearchpath.FindFile(startupfile,false,result) then
-       result:='/usr/lib/'+startupfile
+       if sysutils.fileexists('/usr/lib/'+startupfile) then
+         result:='/usr/lib/'+startupfile
+       else if
sysutils.fileexists('/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/lib/'+startupfile)
then
+
result:='/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/lib/'+startupfile
     end
   else
     result:='';
Post by Michael Ring
This small patch helped me to get rid of the need to define
-XR/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/ in /etc/fpc.cfg
It would be greet to have something similar in the upcoming 3.0.5
release (and of course in trunk) so that also building lazarus with a
3.0.5 compiler works (It currently fails without the entry in fpc.cfg)
Michael
Index: compiler/systems/t_bsd.pas
===================================================================
--- compiler/systems/t_bsd.pas    (revision 39358)
+++ compiler/systems/t_bsd.pas    (working copy)
@@ -248,6 +248,9 @@
             system_i386_darwin,
               begin
+                { 10.14 and later: crt1.o }
+                if CompareVersionStrings(MacOSXVersionMin,'10.14')>=0 then
+                  exit('crt1.so');
                 { 10.8 and later: no crt1.* }
                 if CompareVersionStrings(MacOSXVersionMin,'10.8')>=0 then
                   exit('');
@@ -377,7 +380,10 @@
   if startupfile<>'' then
     begin
      if not librarysearchpath.FindFile(startupfile,false,result) then
-       result:='/usr/lib/'+startupfile
+       if sysutils.fileexists('/usr/lib/'+startupfile) then
+         result:='/usr/lib/'+startupfile
+       else if
sysutils.fileexists('/Library/Developer/CommandLineTools//SDKs/MacOSX.sdk/usr/lib/'+startupfile)
then
+
result:='/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/lib/'+startupfile
     end
   else
     result:='';
Post by Michael Ring
I only adjusted -Fl to match the current version installed, having a
wrong issue there did not change the build behaviour. The change
necessary was to include
-XR/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/
otherwise fpcmake will not compile.
Cross-Compiling did however not work, the makefile of fpcmake does
seem to support FPCOPT but somehow the parameter does not get
/Library/Developer/CommandLineTools/usr/bin/make -C utils/fpcm
bootstrap FPC=/Users/ring/devel/fpc-arm/compiler/ppcrossarm
FPCFPMAKE=/Users/ring/devel/fpc-arm/compiler/ppc RELEASE=1 'OPT='
/Users/ring/devel/fpc-arm/compiler/ppc fpcmake.pp -n
-Fu/Users/ring/devel/fpc-arm/rtl/units/x86_64-darwin
-FU/Users/ring/devel/fpc-arm/utils/fpcm/units/x86_64-darwin
ld: file not found: /usr/lib/crt1.10.5.o
An error occurred while linking
I could make crosscompiling work by doing this (Use OPT instead of FPCOPT)
make clean buildbase CROSSINSTALL=1 OS_TARGET=embedded CPU_TARGET=arm
SUBARCH=$SUBARCH CROSSOPT="$CROSSOPT" BINUTILSPREFIX=arm-none-eabi-
OPT="-XR/Library/Developer/CommandLineTools//SDKs/MacOSX.sdk/"
I hope that hardcoding the path
/Library/Developer/CommandLineTools//SDKs/MacOSX.sdk/ in FPC will
solve this.....
Thank you,
Michael
Post by Jonas Maebe
Post by Michael Ring
make clean buildbase CPU_TARGET=x86_64 INSTALL_PREFIX=$HOME/3.1.1
FPCOPT="-XR/Library/Developer/CommandLineTools//SDKs/MacOSX.sdk/"
#ifdef cpui386
-XR/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/
-Fl/Library/Developer/CommandLineTools/usr/lib/clang/10.0.0
#endif
#ifdef cpux86_64
-XR/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/
-Fl/Library/Developer/CommandLineTools/usr/lib/clang/10.0.0
#endif
both actions were needed for a successful compile...
What errors do you get if you don't include the -Fl option?
Post by Michael Ring
Is there a better way to make compiles work on Mojave?
The -XR above seems to be the correct way to handle this change. We
could also hard code that search path in the compiler in addition to
/usr/lib
Jonas
_______________________________________________
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel
_______________________________________________
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel
_______________________________________________
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel
_______________________________________________
fpc-devel maillist - fpc-***@lists.freepascal.org
http://lists.freepascal.org/cg

Loading...