Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-devel / 2018-07

MacOS Mojave beta - crt1.o not installed to /usr/lib

5 messages · 2 people ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Michael Ring

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

Reply by email

Jonas Maebe
to Michael Ring
Michael Ring wrote 16 lines
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...

What errors do you get if you don't include the -Fl option?

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

Reply by email

Michael Ring
to Jonas Maebe

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

Jonas Maebe wrote 31 lines
On 01/07/18 22:18, Michael Ring wrote: > > 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... What errors do you get if you don't include the -Fl option? > 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  -  http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel

Reply by email

Michael Ring
to 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,
             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:='';

Michael Ring wrote 78 lines
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 Am 01.07.18 um 22:34 schrieb Jonas Maebe: > On 01/07/18 22:18, Michael Ring wrote: >> >> 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... > > What errors do you get if you don't include the -Fl option? > >> 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  -  > http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel _______________________________________________ fpc-devel maillist  -  http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel

Reply by email

Michael Ring
to Michael Ring

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:='';

Michael Ring wrote 128 lines
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:=''; Am 01.07.18 um 22:52 schrieb 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 > 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 > > > > Am 01.07.18 um 22:34 schrieb Jonas Maebe: >> On 01/07/18 22:18, Michael Ring wrote: >>> >>> 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... >> >> What errors do you get if you don't include the -Fl option? >> >>> 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  -  >> http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel > > _______________________________________________ > fpc-devel maillist  -  > http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel _______________________________________________ fpc-devel maillist  -  http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel

Reply by email