I have a code base which under Xcode get the error "bad instruction" for every NEON instruction I call. It basically seems like NEON is not detected.
I am attempting to build a static library, I went to New Project, selected Cocoa Touch Static Library, then added my existing files.
Everything I'm reading indicates that NEON should be already enabled. I removed all references to armv6, and am targeting iOS 5.1
Also the code in question is all contained as routines defined in ".s" files -- pure assembly. I am not using the intrinsic method calls.
this is the error which I get whenever I try to run the code:
unknown directive .fpu neon
Command /Applications/Xcode.app/Contents/Developer/Toolchains/
XcodeDefault.xctoolchain /usr/bin/clang failed with exit code 1
also when I delete .fpu neon command from my code, it compiles and I get the .o file but then it fails to link as I still am not able to use the programs defined in the code file.
Try the answer on my similar question https://stackoverflow.com/a/10507325/571778
Sort answer, in my case, was I was porting assembly from another compiler. A few points:
Xcode requires all lower case instructions
The pseudo-ops are different (try http://www.shervinemami.info/armAssembly.html#template)
you must start your assembly function names with "_", because that's how the linker finds them (in C, call "foo()", but in ASM name your function "_foo")
Related
I am trying to port QT5 application to iOS. It builds and runs fine with QtCreator, but now I am trying to make manual XCode project. Next steps are gatheres from another topics, here is my final path:
It builds and runs, but I got runtime error:
Error: You are creating QApplication before calling UIApplicationMain.
I've found, that I should replace main -> qtmn, but then I got error about no entry point.
The declaration of main is inside of libqios.a, but I am unable to tell linker "Take main() from libqios, not from cpp files."
I tried it with
-Wl,-force_load,$(QT_SDK)/plugins/platforms/libqios.a - but it does nothing.
I found, that QT preprocessor makes something with object files (renaming main into something others), but it looks too horrible. How can it be solved?
Succeeded in by: renaming main -> qtmn (in qt sourced), rebuilt QT, and called qt_main_wrapper from my main().
I'm trying to compile a dependent libraries from the source code and I've got this error:
/Applications/Xcode.app/Contents/Developer/Platforms/AppleTVOS.platform/Developer/SDKs/AppleTVOS9.0.sdk/usr/include/unistd.h:446:8:
note: 'fork' has been explicitly marked unavailable here pid_t
fork(void) __WATCHOS_PROHIBITED __TVOS_PROHIBITED;
Is there any way to resolve this issue?
The thing is that I don't actually even need this functionality. When I compile this code for iOS and run it under tvOS then it works.
But I can not submit the application because it contains code compiled for iOS.
What would be the good trick to substitute there a dummy fork() function so it compiles OK (believing that it is not actually used by my specific use-cases).
I don't believe there is a way round this. You cannot create processes under iOS and tvOS is 90% iOS, so the same restriction applies.
You'll have to conditionally compile-out that section of code for iOS/tvOS.
Address-Sanitizer https://code.google.com/p/address-sanitizer/wiki/AddressSanitizer
I have compile my own llvm (pretty straight forward compiling) because apple's llvm not support this function.
I have tested the clang for mac command line program, it works (but without showing the line the sourcecode).
for iOS, there is still some problems:
compile simulator version : report error for pre-compiled header:
In file included from /Users/fluke/Documents/projects/tmp/testAsanNoARC/testAsanNoARC/testAsanNoARC-Prefix.pch:12:
In file included from /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator6.1.sdk/System/Library/Frameworks/UIKit.framework/Headers/UIKit.h:9:
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator6.1.sdk/System/Library/Frameworks/UIKit.framework/Headers/UIAccelerometer.h:53:24: error: 'UIAccelerometer' is unavailable: not available on OS X
- (void)accelerometer:(UIAccelerometer *)accelerometer didAccelerate:(UIAcceleration *)acceleration NS_DEPRECATED_IOS(2_0, 5_0);
^
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator6.1.sdk/System/Library/Frameworks/UIKit.framework/Headers/UIAccelerometer.h:33:12: note: declaration has been explicitly marked unavailable here
#interface UIAccelerometer : NSObject {
^
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator6.1.sdk/System/Library/Frameworks/UIKit.framework/Headers/UIAccelerometer.h:53:71: error: 'UIAcceleration' is unavailable: not available on OS X
- (void)accelerometer:(UIAccelerometer *)accelerometer didAccelerate:(UIAcceleration *)acceleration NS_DEPRECATED_IOS(2_0, 5_0);
...
compile for device version, it reports lack of libarc (but actually I don't enable ARC)
ld: file not found: /Users/fluke/Documents/tools/asan/Debug+Asserts/lib/arc/libarclite_iphoneos.a
clang: error: linker command failed with exit code 1 (use -v to see invocation)
so I try use it for a separate lib - just new a lib target and use my own clang while the main target still use apple's llvm. the program compiles ( may need to link to the asan dylib in the built llvm), but not work because I asan need to be loaded before our program entry.
who have experience with doing this?
I finally get the asan work for me with my friend's help.
move all c/c++ code to a new target (cocoa lib target) of xcode project. make the project build and run normally as it was a single app before separate c/c++ codes to a lib.
build llvm. ref http://blog.wadetregaskis.com/tot-clang-llvm-in-xcode/
add a clang option to xcode. for convenient you can use this template: http://blog.wadetregaskis.com/tot-clang-llvm-in-xcode/ . change clang path to the clang just build in the previous step.
change the lib target in the xcode to use the new clang/llvm, add a cflag -fsanitize=address. then build, if some api (such as opengl/system video function) is reported not supported, then you can put it into the app project, your clang doesn't support compiling it.
if you pass the compile, it will report linkage problem of __asan_xxx function, add a lib called "libclang_rt.asan_osx_dynamic.dylib" to the app's linkage dependency, and it's located in your llvm's
./Debug+Asserts/lib/clang/3.4/lib/darwin/ folder.
then you need to specified the out put file or else the report will goes to the stdout with color characters which will confuse you. put this lines into your main.m:
extern void __sanitizer_set_report_path(const char *path);
__sanitizer_set_report_path("/tmp/asan.txt");
then you can make your program some memory error such as use after free or heap buffer overflow. the asan will let the program crash in the first error, with /tmp/asan.txt.number report generated.
you're almost there, the report show's the error stack with the file's offset. all you need to do is one more step - resolve the address to code line. you need to find the DWARF file of your project, then use a tool called asan_symbolize.py to generate the new report with source code line. you can goole asan_symbolize.py then get and fix this script to use the DWARF file. you can find the DWARF file by right click your production app, select show in finder, then to up a level to get the iphone simulator directory, open the bundle called your.app.dSYM, then you can get the DWARF in ./Content/Resources/DWARF.
The only thing that I haven't list here is the modified asan_symbolize.py, you can modify it by your self, it has no magic, you just correct some path and it will work.
The errors listed in the original post have little to do with ASan itself. Most certainly you would've got them without the -fsanitize=address flag.
Building and running for iOS isn't supported yet, however you can build an app targeting the iOS simulator - it should work just fine.
Please don't hesitate to direct further questions to address-sanitizer#googlegroups.com
I have a code base which compiles fine in all other NEON compilers, ndk-build, RVDS, etc, but under Xcode I get the error "bad instruction" for every NEON instruction I call. It basically seems like NEON is not detected.
I am attempting to build a static library, I went to New Project, selected Cocoa Touch Static Library, then added my existing files.
Everything I'm reading indicates that NEON should be already enabled. I removed all references to armv6, and am targeting iOS 5.1
Also the code in question is all contained as routines defined in ".s" files -- pure assembly. I am not using the intrinsics method calls.
It seems like the compiler is barfing on the whole file...
Unknown pseudo-op: .cpu
It lists all of the other settings, like .fpu, etc
Here are my current settings:
(source: wasteonline.net)
(source: wasteonline.net)
(source: wasteonline.net)
After the as tool I mentioned in my last answer turned out to be choking on my syntax as well, I realized there must be something else going on.
I followed the guidelines on the bottom of this post http://www.shervinemami.info/armAssembly.html#template
The changes I needed to make were:
converted my instructions to all lower case
use the naming directives to be compatible with mach-o (solved linker problems)
Try to use GCC4.2. I solved a very similar problem switching to the old, good GCC.
In Build Settings -> Compiler for C/C++/Objective-C, select GCC
Actually, if you check the LLVM ARM status page, you'll see that it cannot yet parse .S files.
I use statically linked sqlite database and in order to compile every next version I sometimes have to do minor changes in the list of object files used.
But sometimes the changes I have to make puzzles me.
For example prior to version 3_6_10 this order
{$L 'Objs\is.OBJ'}
{$L 'Objs\mbisspc.OBJ'}
was ok, but starting 3_6_12 the linker said
unsatisfied forward or external declaration _isspace
but changing the order to
{$L 'Objs\mbisspc.OBJ'}
{$L 'Objs\is.OBJ'}
helped.
As for the changes in sqlite, it really stopped to use c function isspace in 3_6_12 and started to use an internal equivalent so "isspace" keyword even don't appear inside the obj file.
So why does the order of linked object file with $L directive matter and where I can read more about this? I suppose it is something related to cross-usage of the listed obj files, but I will feel more safe if I understand what is going on
Thanks
Edit:
As of the comment by David Heffernan linking to his answer to this other question on linking .obj file in Delphi, I replaced linker by compiler, and added a the italic portion below:
C compilers use a multi-pass linker compiler that knows how to resolve forward and circular dependencies between .obj files.
Since the Delphi linker compiler is targeted at the Delphi language, and the Delphi language does not allow for that, the linker compiler does not allow for this either.
Pro: the linker compiler is much faster.
Con: you need to help the linker compiler a bit by placing the .obj files in the right order
, or by manually resolving the dependencies (see the above mentioned answer by David Heffernan)
.
--jeroen