Cross compilation for linux failed on Mac


(Iliya Trub) #1

Dear colleagues,
It seems to me, something was happened with cross-compilation on MacOS. I have successfully built all libraries for 32-bit ARM architecture and then built applications and libraries on Ubuntu 15 with x86_64 Swift compiler, pointing out --target=armv7-unknown-linux-gnueabi and placing arm-libraries at convenient places.
Then I built from the same sources swift-compiler on Macintosh and tried to do the same, but swiftc wrote, that target armv7-unknown-linux-gnueabi (or arm-linux-gnueabi)
is unknown for it! I exactly remember, that two months ago cross-compilation on Mac worked with target=arm-linux-gnueabi, but now does not.
I continued experiments and found, that swiftc recognizes target=armv7-apple-macosx10.11
I pointed out this target and placed libraries and modules, but I received:

module file was created by a newer version of the compiler: <path to arm Swift.swiftmodule>

I was wondered, because sources are absolutely the same.
Output of swiftc --version on Mac:
Swift version 3.0-dev (LLVM 0d07a5d3d5, Clang 11493b0f62, Swift c6a0f51611)
Target: x86_64-apple-macosx10.9

Output of swiftc --version on ARM-emulator:
Swift version 3.0-dev (LLVM , Clang , Swift )
Target: armv7l-unknown-linux-gnueabi

How you can explain all these things? May be, cross-compilation on Mac is now prohibited for linux platforms? I can not imagine other reasons.
Thanks in advance for answer.


(Iliya Trub) #2

So, I cancel my question since it was incorrect. I pointed out arm-linux target with "xcrun -sdk macosx" before swiftc, so all targets unless native were rejected. But I have once more interesting question about compiler behaviour.
All below written actions are done on Mac. I invoke swiftc:
1) without xcrun
2) with native target x86_64-apple-macosx10.9
3) with -c option and one short-length source .swift-file, that create simple custom ObjC instance
4) with -import-objc-header option and name of .h-file, that contains one line #import "C.h", where my simple custom interface is declared
5) with Xcc -I options, which contain paths to ObjC open source frameworks and ObjC open source runtime (not native)
The result is bridging header is successfully imported, so open source frameworks, pointed out at XCcc -I, are found and used.

Then let us do another experiment. Write --target=arm-linux-gnueabi and add -I<path to armv7-linux-gnueabi swift.swiftmodule>, where arm-linux module was build within native environment on linux host. In that case, bridging header import is failed, code failed within CLangImporter::importHeader() since many, many errors in clang diagnostics: cland does not understand any ObjC expression or classname in my headers and can not build AST. I think, this phenomena is explained by some differences in swift.swiftmodule, built on mac and on linux. So, my question is: what just exactly this difference is? What part of swift.swiftmodule is reponsible for such behaviour and where this part is analyzed in compiler source code? Thanks in advance for answer this interesting question.

···

17.03.2016, 22:32, "���� ���� via swift-dev" <swift-dev@swift.org>:

Dear colleagues,
It seems to me, something was happened with cross-compilation on MacOS. I have successfully built all libraries for 32-bit ARM architecture and then built applications and libraries on Ubuntu 15 with x86_64 Swift compiler, pointing out --target=armv7-unknown-linux-gnueabi and placing arm-libraries at convenient places.
Then I built from the same sources swift-compiler on Macintosh and tried to do the same, but swiftc wrote, that target armv7-unknown-linux-gnueabi (or arm-linux-gnueabi)
is unknown for it! I exactly remember, that two months ago cross-compilation on Mac worked with target=arm-linux-gnueabi, but now does not.
I continued experiments and found, that swiftc recognizes target=armv7-apple-macosx10.11
I pointed out this target and placed libraries and modules, but I received:

module file was created by a newer version of the compiler: <path to arm Swift.swiftmodule>

I was wondered, because sources are absolutely the same.
Output of swiftc --version on Mac:
Swift version 3.0-dev (LLVM 0d07a5d3d5, Clang 11493b0f62, Swift c6a0f51611)
Target: x86_64-apple-macosx10.9

Output of swiftc --version on ARM-emulator:
Swift version 3.0-dev (LLVM , Clang , Swift )
Target: armv7l-unknown-linux-gnueabi

How you can explain all these things? May be, cross-compilation on Mac is now prohibited for linux platforms? I can not imagine other reasons.
Thanks in advance for answer.
_______________________________________________
swift-dev mailing list
swift-dev@swift.org
https://lists.swift.org/mailman/listinfo/swift-dev