compdzwio / ios-toolchain-based-on-clang-for-linux

Automatically exported from code.google.com/p/ios-toolchain-based-on-clang-for-linux
0 stars 0 forks source link

Several problems compiling the ios toolchain from 32bits GNU/Linux. #6

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
I've encountered some problems to compile the ios toolchain from 32bits 
GNU/Linux. But after some modifications i was able to compile the complete 
toolchain, since i think this might be helpful to fix some bugs, i've writed 
some changes that i need to make to be able to compile the toolchain.

cctools-836 and gdb-1822-for-linux:
========================================================================

comment __int_64_t and __uint64_t definition from types.h ( otherwise it will 
complain about the double declaration of this two types )
//__extension__ typedef signed long long int __int64_t;
//__extension__ typedef unsigned long long int __uint64_t;
in
/usr/include/bits/types.h
then recomment this...

in Snapshot.cpp
#include <Block.h>
must be
#include <BlocksRuntime/Block.h>

building ld needs -luuid to compile:
/bin/sh ../libtool --tag=CC   --mode=link clang -D__DARWIN_UNIX03 -luuid 
-I../include -I../include/foreign -I../libstuff -Wall -Wno-long-long 
-Wno-import -Wno-format -Wno-deprecated -Wno-unused-variable 
-Wno-invalid-offsetof -DLTO_SUPPORT=1 -D__LITTLE_ENDIAN__=1 -DDEBUG -g -O2   -o 
ld_classic ld_classic-ld.o ld_classic-pass1.o ld_classic-objects.o 
ld_classic-sections.o ld_classic-cstring_literals.o ld_classic-symbols.o 
ld_classic-fvmlibs.o ld_classic-layout.o ld_classic-specs.o ld_classic-pass2.o 
ld_classic-generic_reloc.o ld_classic-rld.o ld_classic-sets.o 
ld_classic-4byte_literals.o ld_classic-8byte_literals.o 
ld_classic-literal_pointers.o ld_classic-dylibs.o 
ld_classic-indirect_sections.o ld_classic-mod_sections.o 
ld_classic-i860_reloc.o ld_classic-ppc_reloc.o ld_classic-m88k_reloc.o 
ld_classic-hppa_reloc.o ld_classic-sparc_reloc.o 
ld_classic-coalesced_sections.o ld_classic-uuid.o ld_classic-debugcompunit.o 
ld_classic-debugline.o ld_classic-arm_reloc.o ../libstuff/libstuff.la

iphonesdk-utils-1.5:
========================================================================

libplutil doesn't come with the plist subfolder includes:
i downloaded the files from: https://github.com/JonathanBeck/libplist

getLocalizedStringFromFile.cpp replace line 96 from ( expects a reference ):
&targetOptions);
to
targetOptions);

gdb-1822-for-linux:
========================================================================

depends on -lCoreFoundation
gcc 
-I/home/downloads/temp/ios-toolchain/gdb-1822-for-linux/opencflite-476.19.0/incl
ude -DTARGET_ARM -I./macosx -o gdb gdb.o cli-dump.o cli-decode.o cli-script.o 
cli-cmds.o cli-setshow.o cli-utils.o cli-logging.o cli-interp.o mi-out.o 
mi-console.o mi-cmds.o mi-cmd-env.o mi-cmd-var.o mi-cmd-break.o mi-cmd-stack.o 
mi-cmd-file.o mi-cmd-disas.o mi-symbol-cmds.o mi-interp.o mi-main.o mi-parse.o 
mi-getopt.o mi-common.o  libgdb.a ../readline/libreadline.a 
-L/home/downloads/temp/ios-toolchain/gdb-1822-for-linux/gdb-1822-for-linux/opcod
es 
-L/home/downloads/temp/ios-toolchain/gdb-1822-for-linux/gdb-1822-for-linux/opcod
es/.libs 
/home/downloads/temp/ios-toolchain/gdb-1822-for-linux/gdb-1822-for-linux/opcodes
/.libs/libopcodes.a 
-L/home/downloads/temp/ios-toolchain/gdb-1822-for-linux/gdb-1822-for-linux/bfd 
-L/home/downloads/temp/ios-toolchain/gdb-1822-for-linux/gdb-1822-for-linux/bfd/.
libs 
/home/downloads/temp/ios-toolchain/gdb-1822-for-linux/gdb-1822-for-linux/bfd/.li
bs/libbfd.a 
-L/home/downloads/temp/ios-toolchain/gdb-1822-for-linux/gdb-1822-for-linux/libib
erty -liberty -lncurses -lm 
-L/home/downloads/temp/ios-toolchain/gdb-1822-for-linux/binary -lCoreFoundation 
-ldl -luuid -lsqlite3

After installing the toolchain:
=========================================================================

arm-apple-darwin11-ar always segfaults

ios clang need to use arm-apple-darwin11-ld, but it tries to use the default ld:
example:

ios-clang -objc-arc -fblocks -g0 -O2 -I"." -framework Foundation  -framework 
UIKit  RootViewController.o main.o HelloWorldApplication.o -o HelloWorld
/usr/bin/ld: unrecognized option '-dynamic'

if i replace symlink ld to the arm ld it works...

static library test fails:
ios-clang -c -objc-arc -fblocks -g0 -O2 -I"." StaticTest.m -o StaticTest.o
arm-apple-darwin11-ar cr libStaticTest.a StaticTest.o
/home/apps/ios/bin/arm-apple-darwin11-ranlib: archive member: 
libStaticTest.a(StaticTest.o) size too large (archive member extends past the 
end of the file)
arm-apple-darwin11-ar: internal ranlib command failed

It's not possible to static link libgcc and libstdc++ ( -static-libgcc 
-static-libstdc++ ), this works in the os x toolchain.

I was able to compile some demo applications changing the default ld and 
avoiding the use of arm-apple-darwin11-ar.

Thanks for all, let me know if i can help in anything.

Original issue reported on code.google.com by spart...@gmail.com on 28 Dec 2012 at 6:35

GoogleCodeExporter commented 8 years ago
Thanks for your report.

cctools issue fixed in svn:
1, BlocksRuntime header problem had been fixed, add a include dir in Makefile.am
2, uuid link problem had been fixed, add UUID_LIBS to LDADD in ld/Makefile.am

iphonesdk-utils issue had been fixed in svn:

1, the header problem of libplutil of iphonesdk-utils had been fixed in svn, 
all headers of plist was lost when "make dist" since they are not added to 
Makefile.am .

2, genLocalization problem had been fixed after llvm/clang 3.2 released. the 
API had changed between 3.2/3.3svn, now it should works with 3.2/3.3svn.

For other issues:
1, change default system header files is not a good idea, we should change our 
codes, please give more information on it.

2, Please consider add symbol links of arm-apple-darwin11-* to /usr/bin, 
otherwise clang may not find proper linker and related commands. It seems a 
problem of clang/llvm. So my suggestion is to install them to /usr/bin, since 
there are no conflicts with system command.

3, Static link libgcc and libstdc++ need the static library of libgcc/libstdc++ 
for iOS sdk, I checked the iOS sdk , it only provides dylib for these 
libraries. we have two choice: build llvm gcc for linux or copy them frome 
Xcode.

ar segfaults problems need more information, please try to debug it and give 
more clues.

Original comment by cjac...@gmail.com on 29 Dec 2012 at 3:58

GoogleCodeExporter commented 8 years ago
AR seg fault can be fixed in issue 7.

Original comment by titan....@gmail.com on 5 Jan 2013 at 2:36

GoogleCodeExporter commented 8 years ago
I am not sure whether this issue cause the problem. As I remember, I use a 
malloc there and should be fixed in the download tarball.

The reported shows :

"static library test fails:
ios-clang -c -objc-arc -fblocks -g0 -O2 -I"." StaticTest.m -o StaticTest.o
arm-apple-darwin11-ar cr libStaticTest.a StaticTest.o
/home/apps/ios/bin/arm-apple-darwin11-ranlib: archive member: 
libStaticTest.a(StaticTest.o) size too large (archive member extends past the 
end of the file)
arm-apple-darwin11-ar: internal ranlib command failed"

Original comment by cjac...@gmail.com on 6 Jan 2013 at 7:32

GoogleCodeExporter commented 8 years ago
i have the same trouble as op with regard to installing ios-toolchain on my 
linux 32-bit

3.9.9 kernel
32-bit Arch Linux
GCC 4.8.1

installing via Arch packaging system or building directly from latest source 
yielded the same errors:

1.
"../include/foreign/i386/_types.h:46:19: error: typedef redefinition with
      different types ('long' vs 'long long')
typedef long int                __int64_t;

/usr/include/bits/types.h:46:44: note: previous definition is here
__extension__ typedef signed long long int __int64_t;"

2.
"../include/foreign/i386/_types.h:47:27: error: typedef redefinition with
      different types ('unsigned long' vs 'unsigned long long')
typedef unsigned long int       __uint64_t;

/usr/include/bits/types.h:47:46: note: previous definition is here
__extension__ typedef unsigned long long int __uint64_t;"

and here is the corrosponding block for the types.h header file from my system:

"#if __WORDSIZE == 64
typedef signed long int __int64_t;
typedef unsigned long int __uint64_t;
#elif defined __GLIBC_HAVE_LONG_LONG
__extension__ typedef signed long long int __int64_t;
__extension__ typedef unsigned long long int __uint64_t;
#endif"

--------------------------

Original comment by Hallous...@gmail.com on 3 Aug 2013 at 4:59

GoogleCodeExporter commented 8 years ago
[deleted comment]
GoogleCodeExporter commented 8 years ago
[deleted comment]
GoogleCodeExporter commented 8 years ago
I found the issue causing the   size too large (archive member extends past the 
end of the file)   error.

It's in the archiver itself, it's because off_t has a different size on 32 bit 
systems.

Diff: 
https://github.com/tpoechtrager/cctools-port/commit/643e5937708c429fa06b2a26bbab
b05800bbd232
Fixed package: 
https://github.com/tpoechtrager/cctools-port/archive/cctools-845-ld64-134.9-1.ta
r.gz

Feel free to backport the fixes from my fork.

Original comment by t.poecht...@gmail.com on 15 Dec 2013 at 9:40

GoogleCodeExporter commented 8 years ago
Yes, i was with same errors and i am using Arch Linux 32-bit

kernel 3.14.23-lts
32-bit Arch Linux
GCC 4.9.2

I have fixed some erros making 2 patchs, attached in this post.

My PKGBUILD is in attach too.

Well, now i am getting that errors:
------------------------------------------------
2 warnings generated.
mv -f .deps/libobjc_la-statics_loader.Tpo .deps/libobjc_la-statics_loader.Plo
/bin/sh ../libtool  --tag=CC --tag=CC  --mode=compile clang -DHAVE_CONFIG_H -I. 
-I..   -D_FORTIFY_SOURCE=2 -std=gnu99 -fPIC -fexceptions 
-Wno-deprecated-objc-isa-usage -DTYPE_DEPENDENT_DISPATCH -DGNUSTEP 
-D__OBJC_RUNTIME_INTERNAL__=1 -D_XOPEN_SOURCE=500 -D__BSD_VISIBLE=1 
-D_BSD_SOURCE=1 -DNO_SELECTOR_MISMATCH_WARNINGS -fno-stack-protector -MT 
libobjc_la-toydispatch.lo -MD -MP -MF .deps/libobjc_la-toydispatch.Tpo -c -o 
libobjc_la-toydispatch.lo `test -f 'toydispatch.c' || echo './'`toydispatch.c
libtool: compile:  clang -DHAVE_CONFIG_H -I. -I.. -D_FORTIFY_SOURCE=2 
-std=gnu99 -fPIC -fexceptions -Wno-deprecated-objc-isa-usage 
-DTYPE_DEPENDENT_DISPATCH -DGNUSTEP -D__OBJC_RUNTIME_INTERNAL__=1 
-D_XOPEN_SOURCE=500 -D__BSD_VISIBLE=1 -D_BSD_SOURCE=1 
-DNO_SELECTOR_MISMATCH_WARNINGS -fno-stack-protector -MT 
libobjc_la-toydispatch.lo -MD -MP -MF .deps/libobjc_la-toydispatch.Tpo -c 
toydispatch.c  -fPIC -DPIC -o .libs/libobjc_la-toydispatch.o
In file included from toydispatch.c:1:
In file included from /usr/include/pthread.h:21:
/usr/include/features.h:148:3: warning: "_BSD_SOURCE and _SVID_SOURCE are 
deprecated, use _DEFAULT_SOURCE" [-W#warnings]
# warning "_BSD_SOURCE and _SVID_SOURCE are deprecated, use _DEFAULT_SOURCE"
  ^
/usr/include/features.h:328:4: warning: _FORTIFY_SOURCE requires compiling with 
optimization (-O) [-W#warnings]
#  warning _FORTIFY_SOURCE requires compiling with optimization (-O)
   ^
2 warnings generated.
mv -f .deps/libobjc_la-toydispatch.Tpo .deps/libobjc_la-toydispatch.Plo
/bin/sh ../libtool  --tag=CC  --mode=compile gcc -DHAVE_CONFIG_H -I. -I..   
-D_FORTIFY_SOURCE=2  -fno-stack-protector -MT block_trampolines.lo -MD -MP -MF 
.deps/block_trampolines.Tpo -c -o block_trampolines.lo block_trampolines.S
libtool: compile:  gcc -DHAVE_CONFIG_H -I. -I.. -D_FORTIFY_SOURCE=2 
-fno-stack-protector -MT block_trampolines.lo -MD -MP -MF 
.deps/block_trampolines.Tpo -c block_trampolines.S  -fPIC -DPIC -o 
.libs/block_trampolines.o
mv -f .deps/block_trampolines.Tpo .deps/block_trampolines.Plo
/bin/sh ../libtool  --tag=CC  --mode=compile gcc -DHAVE_CONFIG_H -I. -I..   
-D_FORTIFY_SOURCE=2  -fno-stack-protector -MT objc_msgSend.lo -MD -MP -MF 
.deps/objc_msgSend.Tpo -c -o objc_msgSend.lo objc_msgSend.S
libtool: compile:  gcc -DHAVE_CONFIG_H -I. -I.. -D_FORTIFY_SOURCE=2 
-fno-stack-protector -MT objc_msgSend.lo -MD -MP -MF .deps/objc_msgSend.Tpo -c 
objc_msgSend.S  -fPIC -DPIC -o .libs/objc_msgSend.o
objc_msgSend.x86-32.S: Assembler messages:
objc_msgSend.x86-32.S:92: Error: junk `.get_pc_thunk.bx' after expression
objc_msgSend.x86-32.S:96: Error: junk `.get_pc_thunk.bx' after expression
objc_msgSend.x86-32.S:100: Error: junk `.get_pc_thunk.bx' after expression
Makefile:504: recipe for target 'objc_msgSend.lo' failed
make[2]: *** [objc_msgSend.lo] Error 1
make[2]: Leaving directory 
'/home/mnemonic/.aur/ios-toolchain/ios-toolchain/src/ios-toolchain-1.1/libobjc2'
Makefile:393: recipe for target 'all-recursive' failed
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory 
'/home/mnemonic/.aur/ios-toolchain/ios-toolchain/src/ios-toolchain-1.1'
Makefile:324: recipe for target 'all' failed
make: *** [all] Error 2
==> ERROR: A failure occurred in build().
    Aborting...
-------------------------------------------------------

How can i fix this problem? Thanks in advance!

PS. I don´t speak english very well, so, sorry for english erros.

Original comment by semei...@gmail.com on 12 Nov 2014 at 6:53

Attachments: