Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

arm64 support #6

Closed
dmigous opened this issue Dec 23, 2014 · 29 comments
Closed

arm64 support #6

dmigous opened this issue Dec 23, 2014 · 29 comments

Comments

@dmigous
Copy link

dmigous commented Dec 23, 2014

I am trying to build cctools for arm64 under Fedora Linux

./configure --target=arm64-apple-darwin
checking build system type... i686-pc-linux-gnu
checking host system type... i686-pc-linux-gnu
checking target system type... Invalid configuration arm64-apple-darwin': machinearm64-apple' not recognized
configure: error: /bin/sh ./config.sub arm64-apple-darwin failed

Maybe you know what can cause this issue?

@dmigous
Copy link
Author

dmigous commented Dec 23, 2014

If I do

./configure --target=aarch64-apple-darwin

then it passes futher but ends up with
...
checking uuid/uuid.h usability... yes
checking uuid/uuid.h presence... yes
checking for uuid/uuid.h... yes
configure: error: Unsupported target aarch64

@waneck
Copy link

waneck commented Dec 23, 2014

Have you tried configuring it as arm-apple-darwin, and compiling to 64bits by passing -m64 to the compiler?

@dmigous
Copy link
Author

dmigous commented Dec 23, 2014

Configure to arm-apple-darwin works successfully. Do you mean -m64 while
compiling cctools? If yes then it is not the case, it means that I will
build cctools to run on 64 bit system. If you mean while building with
cctools and clang for device to set -m64 then I am not sure whether result
will be compatible with arm64.

On Dec 23, 2014 7:51 PM, "Cauê Waneck" notifications@github.com wrote:

Have you tried configuring it as arm-apple-darwin, and compiling to
64bits by passing -m64 to the compiler?


Reply to this email directly or view it on GitHub.

@waneck
Copy link

waneck commented Dec 23, 2014

Yes I meant adding -m64 to your clang flags when compiling to the device.

@tpoechtrager
Copy link
Owner

Try:

./configure --target=arm-apple-darwin
find . -name Makefile -print0 | xargs -0 sed -i "s/arm-apple-darwin/arm64-apple-darwin/g"
make
make install

Need to find a way to prevent automake from checking the --target value.

@dmigous
Copy link
Author

dmigous commented Dec 24, 2014

@tpoechtrager , Thanks for hint. Did you try to do this? Why do you belive that this will get proper results?

@dmigous
Copy link
Author

dmigous commented Dec 24, 2014

Meanwhile, guys, if you are here just interested whether you built something for new Apple iphone 6 processors with arm64 architecture using this toolchain?

@tpoechtrager
Copy link
Owner

Yes, it works. It doesn't matter whatever you pass to --target - cctools/ld64 is always a cross tool.

I need to rename --target to --program-prefix (or something similar) so automake doesn't check its value (automake probably doesn't know about arm64, x86_64h etc.).

Meanwhile, guys, if you are here just interested whether you built something for new Apple iphone 6 processors with arm64 architecture using this toolchain?

This isn't a tool chain, this is just a cctools / ld64 port, but yes, I have successfully built arm64 binaries, but I have no device to test them. However, I assume everything works well.

@tpoechtrager
Copy link
Owner

#3 may be a useful resource for you.
You also need clang 3.5 (or later) for arm64.

@dmigous
Copy link
Author

dmigous commented Dec 24, 2014

This isn't a tool chain, this is just a cctools

yes, you are right. sorry

Do you know what is the difference between arm64 | arm64v8 | aarch64?

@dmigous
Copy link
Author

dmigous commented Dec 24, 2014

ah, what I've learned here that roughly arm64 and aarch64 was different backends and now they merged to aarch64 [http://www.phoronix.com/scan.php?page=news_item&px=MTY5ODk]

Then want to mention that maybe you have to update README.md that for arm64* targets LLVM 3.5 is required

@tpoechtrager
Copy link
Owner

Yes, they are more or less the same. But they didn't merge them - they replaced the existing aarch64 backend with the Apple one and renamed it to aarch64.

@dmigous
Copy link
Author

dmigous commented Dec 24, 2014

@tpoechtrager

Yes, they are more or less the same. But they didn't merge them - they replaced the existing aarch64 backend with the Apple one and renamed it to aarch64.

then better here use aarch64 in place of arm64?

 ./configure --target=arm-apple-darwin
 find . -name Makefile -print0 | xargs -0 sed -i "s/arm-apple-darwin/arm64-apple-darwin/g"
 make
 make install

At least because when I try to do on other projects

./configure --target=arm64-apple-darwin
it doesn't works

but

./configure --target=aarch64-apple-darwin
works.

But on cctools
./configure --target=aarch64-apple-darwin
gives an error. What do you think?

@dmigous
Copy link
Author

dmigous commented Dec 24, 2014

As I know binary built for arm-apple-darwin will work on arm64 processor. Because we did some magick here to overcome autoconf restrictions is there a way to check that library built for arm64 instruction set?

@tpoechtrager
Copy link
Owner

The best workaround for this is to avoid arm64 in the triplet name.

Configure cctools/ld64 with --target arm-apple-darwin10, then in your compiler wrapper
add -arch arm64 to the invocation line (basically the same what's done on OS X when you
are compiling for arm64).

i.e. (see issue 3):

clang -isysroot .... -ios-version-min=... [...] -arch arm64 "$@"

Then you can use

CC=arm-apple-darwin10-clang CXX=arm-apple-darwin10-clang++ ./configure --host=arm-apple-darwin10

to compile arm64 code.

But on cctools
./configure --target=aarch64-apple-darwin
gives an error. What do you think?

Don't use aarch64 for Darwin stuff, it's always arm64 there.

@dmigous
Copy link
Author

dmigous commented Dec 26, 2014

@tpoechtrager

darwin10

does it really matters to put darwin version?

and also want to ask why you did such conclusions about -arch and -target options? Maybe you can explain to me the way you think or give some links to read?

Thank you

@tpoechtrager
Copy link
Owner

does it really matters to put darwin version?

No, doesn't really matter, some build environments may check it though.

and also want to ask why you did such conclusions about -arch and -target options?
Maybe you can explain to me the way you think or give some links to read?

http://clang.llvm.org/docs/CrossCompilation.html#general-cross-compilation-options-in-clang

#3 (comment)

You need to pass -arch to override the default target cpu (probably armv6 or armv7 for
arm-apple-darwin).

@tpoechtrager
Copy link
Owner

@dmigous
Copy link
Author

dmigous commented Dec 29, 2014

@tpoechtrager
Anyway, for me using scheme
arm-apple-darwin-clang++ -target arm-apple-darwin -arch arm64
cannot be common solution for all projects. For example it doesn't work for boost 1.55 /1.57 (didn't check other). I didn't investigated deep the purpose,but just
arm-apple-darwin-clang++ -target arm64-apple-darwin
works fine

@tpoechtrager
Copy link
Owner

You don't need to add -target or -arch, the wrapper does this for you.

@tpoechtrager
Copy link
Owner

Use a pre-built boost package if you don't want to mess around with building: https://github.com/danoli3/ofxiOSBoost.

@dmigous
Copy link
Author

dmigous commented Dec 29, 2014

Use a pre-built boost package if you don't want to mess around with building: https://github.com/danoli3/ofxiOSBoost.

Thanks. I already setup build of boost for ios. Just wanted to show that this doen't work as a common solution.

Reading your wrapper now..

@dmigous
Copy link
Author

dmigous commented Dec 29, 2014

You don't need to add -target or -arch, the wrapper does this for you.

I've read wrapper.. anyway if compiler is arm-apple-darwin-clang++ and IOS_TARGET_CPU=arm64 then you wrapper will produce same kind of string
arm-apple-darwin-clang++ -target arm-apple-darwin -arch arm64 ...

@tpoechtrager
Copy link
Owner

Like I said, the wrapper does it for you.

If arm-apple-darwin-clang is the wrapper, then you don't need to add -target and -arch another time.

@dmigous
Copy link
Author

dmigous commented Dec 30, 2014

@tpoechtrager
have a following question:
when I compile for two instruction-sets:

arm-apple-darwin-clang -target arm-apple-darwin -arch arm64 -arch armv7s -c test.cxx -o test.o

it will produce two temporary object files and then automatically using arm-apple-darwin-lipo will merge them into one fat test.o.

Now when I try to do:

arm-apple-darwin-libtool -static -o libtest.a test.o

am getting following error:

arm-apple-darwin-libtool: no library created (no object files in input files)

Use of -arch_only arm64 option for libtool gives same kind error. If I compile just for one -arch then it works fine! Do you know what can cause this?

P.S. Maybe we should create other messaging thread?

@tpoechtrager
Copy link
Owner

It works for me.

$ arm-apple-darwin11-clang test.c -arch arm64 -arch armv7s -arch armv7 -c

$ arm-apple-darwin11-lipo -info test.o
Architectures in the fat file: test.o are: armv7s armv7 arm64

$ arm-apple-darwin11-libtool -static -o libtest.a test.o

$ arm-apple-darwin11-lipo -info libtest.a
Architectures in the fat file: libtest.a are: armv7s armv7 arm64 

@dmigous
Copy link
Author

dmigous commented Nov 2, 2015

this issue were solved by using for -target flag just arm-apple-darwin (instead of arm64-apple-darwin) and for -arch flag arm64. Hence my CFLAGS appended with following for armv7, armv7s, arm64 correspondingly

CFLAGS += -target arm-apple-darwin -arch armv7
CFLAGS += -target arm-apple-darwin -arch armv7s
CFLAGS += -target arm-apple-darwin -arch arm64

tested it on all above archs

@dmigous dmigous closed this as completed Nov 2, 2015
@rennhak
Copy link

rennhak commented Nov 2, 2015

Nice, thanks ! :)

@jau88
Copy link

jau88 commented Jan 24, 2016

You could use this too.

echo 'echo arm-apple-darwin' > config.sub

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants