From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 14908 invoked by alias); 3 Aug 2012 12:01:35 -0000 Received: (qmail 14899 invoked by uid 22791); 3 Aug 2012 12:01:34 -0000 X-SWARE-Spam-Status: No, hits=-2.6 required=5.0 tests=AWL,BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,KHOP_RCVD_TRUST,RCVD_IN_DNSWL_LOW,RCVD_IN_HOSTKARMA_YE,TW_BF,TW_CP,URI_HEX X-Spam-Check-By: sourceware.org Received: from mail-ee0-f41.google.com (HELO mail-ee0-f41.google.com) (74.125.83.41) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Fri, 03 Aug 2012 12:01:19 +0000 Received: by eeke49 with SMTP id e49so163974eek.0 for ; Fri, 03 Aug 2012 05:01:18 -0700 (PDT) Received: by 10.14.198.200 with SMTP id v48mr1885571een.3.1343995278380; Fri, 03 Aug 2012 05:01:18 -0700 (PDT) Received: from [192.168.1.118] (93-152-137-24.ddns.onlinedirect.bg. [93.152.137.24]) by mx.google.com with ESMTPS id s8sm25207765eeo.8.2012.08.03.05.01.17 (version=TLSv1/SSLv3 cipher=OTHER); Fri, 03 Aug 2012 05:01:18 -0700 (PDT) From: Guetcho Guetchev Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: quoted-printable Subject: please, help me with libffi on iOS porting Message-Id: <32A33156-EC2B-47FF-B3F9-43558704FA6C@gmail.com> Date: Fri, 03 Aug 2012 12:01:00 -0000 To: "libffi-discuss@sourceware.org" Mime-Version: 1.0 (Mac OS X Mail 6.0 \(1485\)) Mailing-List: contact libffi-discuss-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libffi-discuss-owner@sourceware.org X-SW-Source: 2012/txt/msg00221.txt.bz2 Hello guys, I am trying to port Glib and Gstreamer for iOS.=20 Recently I encountered several issues related to the code alignment. First of all I get the following warnings when compiling Glib or whatever l= ibrary depending on libffi: ld: warning: ARM function not 4-byte aligned: _ffi_call_SYSV from /Users/us= er/gstreamer/lib/libffi.a(sysv.o) ld: warning: ARM function not 4-byte aligned: .ffi_call_SYSV_end from /User= s/user/gstreamer/lib/libffi.a(sysv.o) ld: warning: ARM function not 4-byte aligned: _ffi_closure_SYSV from /Users= /user/gstreamer/lib/libffi.a(sysv.o) ld: warning: ARM function not 4-byte aligned: .Lclosure_epilogue from /User= s/user/gstreamer/lib/libffi.a(sysv.o) ld: warning: ARM function not 4-byte aligned: .Lretint from /Users/user/gst= reamer/lib/libffi.a(sysv.o) ld: warning: ARM function not 4-byte aligned: .Lretlonglong from /Users/use= r/gstreamer/lib/libffi.a(sysv.o) ld: warning: ARM function not 4-byte aligned: .ffi_closure_SYSV_end from /U= sers/user/gstreamer/lib/libffi.a(sysv.o) ld: warning: ARM function not 4-byte aligned: _ffi_arm_trampoline from /Use= rs/user/gstreamer/lib/libffi.a(sysv.o)=20 When I dug into the code I found that on several files (sysV.s and trampol= ine.S along with several patches / fixes that are applied to these files ) = where the code alignment is set to 1 byte (.align 0). However the default a= lignment for gcc / clang compilers is 4 bytes. As far as I know for the thumb ARM assembly it is preferable to have 4 byte= s alignment.=20 So is there a reason the alignment is set to 1 byte? But the next issue is worse:=20=20 In ffi_call() I get an assert at line 260: 247: switch (cif->abi)=20 248: { 249: case FFI_SYSV: 250: ffi_call_SYSV (fn, &ecif, cif->bytes, cif->flags, ecif.rvalue); 251: break; 252: 253: case FFI_VFP: 254: #ifdef __ARM_EABI__ 255: ffi_call_VFP (fn, &ecif, cif->bytes, cif->flags, ecif.rvalue); 256: break; 257: #endif 258: 259: default: 260: FFI_ASSERT(0); 261: break; 262: } 263: if (small_struct) 264: memcpy (rvalue, &temp, cif->rtype->size); 265: else if (vfp_struct) 266: memcpy (rvalue, ecif.rvalue, cif->rtype->size); 267: } the value of cfi->abi is FFI_VFP This obviously happens when using the function g_object_set() with a proper= ty from Glib / Gstreamer and when that property is float / double. So I have doubts about the code alignment. As far as I know for the ARM arc= hitectures the float / double should be strictly aligned on 4 byte boundary. My questions here is: why the alignment of sysV.S and trampoline.S is set t= o 1 byte? Is there a need for that? However when I try to change that alignment (by hacking the files that gene= rate / patch the sources - at the end before the actual compilation the ali= gnment is really 4 bytes (.align 2) - so I byuserpass the python scripts th= at apply patches and generate sources) I still get similar issue although I= did not receive any warnings about the alignment of the ffi_ functions. This is by the way using the standard automake (sat up for the cross-compil= ation).=20 The most astonishing thing however is when I try to use xcodebuild tool. I try the following line: xcodebuild install -target 'libffi iOS' -configuration Debug -project libff= i.xcodeproj -arch armv7 DEFAULT_COMPILER=3Dcom.apple.compilers.gcc_4.2 And the last lines of the log are these: setenv XCODE_VERSION_ACTUAL 0440 setenv XCODE_VERSION_MAJOR 0400 setenv XCODE_VERSION_MINOR 0440 setenv YACC yacc /bin/sh -c "\"/Users/user/gstreamer/build/libffi/build/libffi.build/Deb= ug-iphoneos/libffi iOS.build/Script-6C43CC3F1534FF1B00162364.sh\"" SetOwnerAndGroup "user:staff" build/UninstalledProducts/libffi.a cd /Users/user/gstreamer/build/libffi setenv PATH "/Applications/Xcode.app/Contents/Developer/Platforms/iPhon= eOS.platform/Developer/usr/bin:/Applications/Xcode.app/Contents/Developer/u= sr/bin:/opt/local/bin:/opt/local/sbin:/Users/user/.rvm/gems/ruby-1.9.3-p125= /bin:/Users/user/.rvm/gems/ruby-1.9.3-p125@global/bin:/Users/user/.rvm/rubi= es/ruby-1.9.3-p125/bin:/Users/user/.rvm/bin:/usr/bin:/bin:/usr/sbin:/sbin:/= usr/local/bin" /usr/sbin/chown -RH "user:staff" /Users/user/gstreamer/build/libffi/bui= ld/UninstalledProducts/libffi.a chown: /Users/user/gstreamer/build/libffi/build/UninstalledProducts/libffi.= a: No such file or directory Command /usr/sbin/chown failed with exit code 1 ** BUILD FAILED ** The following build commands failed: SetOwnerAndGroup "user:staff" build/UninstalledProducts/libffi.a (1 failure) Obviously the compilation is impossible with apple clang compiler so I had = to change it with gcc 4.2. The build process completes finely. However the = installation procedure fails. Guys, have you tried the actual installation? By simply building the xcodep= roj file you can't get the executables. The option "build" of xcodebuild do= es not produce (or at least I don't see) actual lib files). The option "ins= tall" of xcodebuild fails with some stupid chown failure on a directory Uni= nstalledProduct which never exists. But even if I create this directory int= o the "build" subdirectory the result is the same. Someone messed up the en= vironment variables for the xcodebuild. Tried to play with almost all variables like INSTALL_PATH, DSTROOT, SKIP_IN= STALL etc but the result is always the same. And even when I created the UninstalledProducts subdirectory in build and e= ven I touch-ed an empty file libffi.a into that (build/UninstalledProducts/= ) I get nothing. Well, the installation process finishes with success but the actual length = of libffi.a is set to 0 (as it was after I created it with touch command). After exploring the scripts in build/libffi.build/Debug-iphoneos/libffi iOS= .build directory (named Script-6C43CC3F1534FF1B00162364.sh and Script-6C43C= C3E1534F8E200162364.sh): Script-6C43CC3F1534FF1B00162364.sh : #!/usr/bin/python import subprocess import re import os import errno import sys def main(): with open('src/arm/trampoline.S', 'w') as tramp_out: p =3D subprocess.Popen(['bash', 'src/arm/gentramp.sh'], stdout=3Dtr= amp_out) p.wait() if __name__ =3D=3D '__main__': main() and Script-6C43CC3E1534F8E200162364.sh : #!/bin/sh /usr/bin/python generate-ios-source-and-headers.py I don't get the meaning of their existence. Why are they executed as post-b= uild steps? What are you trying to do with them? In my opinion they should be executed prior the build phase (to patch the s= ources and to generate sources) but not at the final steps. I know its kind awkward but I need libffi to be build by a script instead o= f opening it in Xcode and manual building procedure.=20 I will be glad if I receive answers of these questions. Thank you in advance. FYI: Using Mac OS Mountain Lion (10.8) with Xcode 4.4. Best regards, Getcho