Unable to cross-compile Swift code on linux - swift

When I try compile a swift code on linux (in my x64 machine), with the command swift build -c release --arch arm64 I am getting this error:
<unknown>:0: error: could not find module '_Concurrency' for target 'arm64-unknown-linux-gnu'; found: x86_64-unknown-linux-gnu, at: /home/kleber-manjaro/swift-5.5.2-RELEASE-ubuntu20.04/usr/lib/swift/linux/_Concurrency.swiftmodule
Anyone can tell me what is causing this and how to fix it?

Related

Not able to compile swift on Ubuntu 18.04

I installed swift toolchain using instructions from swift.org. While compiling helloworld code I am getting below error.
warning: 'helloworld': failed loading cached manifest for 'helloworld': disk I/O error
error: 'helloworld': Invalid manifest
<unknown>:0: error: unable to open output file '/usr2/xyz/.cache/clang/ModuleCache/IJ5GUC7XMAO5/SwiftShims-1TLN9ZL6HKTHR.pcm': 'No such file or directory'
<unknown>:0: error: could not build C module 'SwiftShims'
I tried removing '/usr2/xyz/.cache/clang/ModuleCache', but did not work. Please help in resolving this issue.

How can I remove or ignore arguments from the swift compiler

Im trying to use an older xcode toolchain (3.1) with my latest xcode version (10).
Starting with a blank project and trying to build I get the following error.
<unknown>:0: error: unknown argument: '-enable-batch-mode'
<unknown>:0: error: unknown argument: '-enforce-exclusivity=checked'
<unknown>:0: error: unknown argument: '-index-store-path'
Command CompileSwiftSources failed with a nonzero exit code
When I look at the compiler output I can clearly see these parameters being passed (cropped for brevity).
/Library/Developer/Toolchains/swift-3.1-RELEASE.xctoolchain/usr/bin/swiftc **-incremental -module-name MyTestApp -Onone -enable-batch-mode -enforce-exclusivity=checked** -DDEBUG -sdk
Is it possible to tell the compiler to ignore these parameters or remove them somehow?
I had considered building with CLI and cobbling the buuild command together but I need the source to be running in xcode so I can debug an issue with a legacy project.
In the end I just downloaded an older version of xcode and also downloaded device support for my new ios device..... which the older xcode didnt support.

vapor build error: manifest parse error(s)

macOS Height Sierra 10.13.4
Xcode version 9.3
$ swift --version
Apple Swift version 4.1 (swiftlang-902.0.48 clang-902.0.37.1)
Target: x86_64-apple-darwin17.5.0
$ brew info vapor
vapor/tap/vapor: stable 3.1.4.l
https://vapor.codes
/usr/local/Cellar/vapor/3.1.4.l (4 files, 17.0MB) *
Built from source on 2018-04-01 at 23:55:47
From: https://github.com/vapor/homebrew-tap/blob/master/vapor.rb
==> Dependencies
Required: ctls ✔, libressl ✔
$ eval "$(curl -sL check.vapor.sh)"
✅ Xcode 9 is compatible with Vapor 2.
✅ Xcode 9 is compatible with Vapor 3.
✅ Swift 4.1 is compatible with Vapor 2.
✅ Swift 4.1 is compatible with Vapor 3.
$ vapor version
Vapor Toolbox: 3.1.4
I create new project with:
vapor new Hello --template=api
and when I try to build it:
vapor build --verbose
I get the error:
No .build folder, fetch may take a while...
Fetching Dependencies ...
warning: 'fetch' command is deprecated; use 'resolve' instead
/PATH-TO-PROJECT: error: manifest parse error(s):
<module-includes>:5:9: note: in file included from <module-includes>:5:
#import "copyfile.h"
^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.13.sdk/usr/include/copyfile.h:36:10: note: in file included from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Develo. per/SDKs/MacOSX10.13.sdk
/usr/include/copyfile.h:36:
#include <stdint.h>
^
/usr/local/include/stdint.h:59:11: note: in file included from /usr/local/include/stdint.h:59:
# include <stdint.h>
^
/usr/local/include/stdbool.h:4:10: note: in file included from /usr/local/include/stdbool.h:4:
#include <stdbool.h>
^
<unknown>:0: error: could not build Objective-C module 'Darwin'
Building Project [Failed]
Error: execute(1)
Does anyone have any idea what is going wrong there? Thanks in advance!
I found the solution:
$ brew doctor
Please note that these warnings are just used to help the Homebrew maintainers
with debugging if you file an issue. If everything you use Homebrew for is
working fine: please don't worry or file an issue; just ignore this. Thanks!
Warning: Unbrewed header files were found in /usr/local/include.
If you didn't put them there on purpose they could cause problems when
building Homebrew formulae, and may need to be deleted.
Unexpected header files:
/usr/local/include/base.h
/usr/local/include/bcj.h
/usr/local/include/block.h
/usr/local/include/cdefs.h
/usr/local/include/check.h
...
and solved the problem by deleting all "Unbrewed header files" from /usr/local/include/
That is bizarre! Just to confirm you’re in the right folder? If you run swift build does it do the same thing?
I had a similar issue unrelated to brew.
Error: backgroundExecute(code: 1, error: "/path/to/project: error: manifest parse error(s):\nInvalid version string: x.0.0\n", output: "")
My Package file looked like this;
...
.package(url: "https://github.com/../something.git", .upToNextMajor(from: "x.0.0")),
...
Looking into .upToNextMajor(from:) I didn't see any parsing for 'x' so I just went to the github page and found which major version I wanted and replaced it for the placeholder in my package file:
...
.package(url: "https://github.com/../something.git", .upToNextMajor(from: "1.0.0")),
...
This resolved the issue for me, Hope this helps the next person that comes by! upvote if it helps you!

How do I develop bare-metal i.mx6sx code using eclipse?

I was wondering if you could help me with some issues and questions I have for developing for the i.MX6 SoloX in bare-metal. I was looking at this link https://community.nxp.com/docs/DOC-106253 and downloaded the files there to use as an example of how to develop bare-metal c code for the i.MX6.
Then I setup my eclipse environment according to this tutorial https://community.nxp.com/docs/DOC-103736 but just the toolchain because I'm not interested in processor expert.
Since I'm working on Linux I didn't installed the Code Sourcery thing, instead I'm working with the gcc-arm-none-eabi which I installed using:
$ sudo apt-get install gcc-arm-none-eabi
And therefore I had to change the cs-rm and cs-make for rm and make respectively.
And I was able to create an eclipse project with the downloaded code and configure the project to make it work, nevertheless, I had the first error:
main.c:8:19: fatal error: stdio.h: No such file or directory
#include <stdio.h>
^
compilation terminated.
make: *** [cortex_A9/main.o] Error 1
cortex_A9/subdir.mk:24: recipe for target 'cortex_A9/main.o' failed
And I was able to solve it adding "/usr/include" in the include directories at project > properties. But I'm not sure if this is a correct way of solving this error.
After fixing this error I got a new one:
syscalls.c:168:1: error: unknown type name 'caddr_t'
caddr_t _sbrk(int incr)
And for solving that I had to include explicitly the file "/usr/include/x86_64-linux-gnu/sys/types.h" and also I don't know if that is the correct way to solve it.
Now having eliminated those two errors I have the following one:
Building target: imx6-A9.elf
Invoking: Cross ARM C Linker
arm-none-eabi-gcc -mcpu=cortex-a9 -march=armv7-a -marm -mlittle-endian -mfloat-abi=softfp -mfpu=neon -mno-unaligned-access -fno-zero-initialized-in-bss -O0 -g -T "/home/mmalagon/iMX6/MX6SX_hello_MFG/cortex_A9/mx6slx.ld" -nostartfiles -Wl,-Map,"imx6-A9.map" -o "imx6-A9.elf" ./cortex_A9/main.o ./cortex_A9/syscalls.o ./cortex_A9/uart.o
/usr/lib/gcc/arm-none-eabi/4.9.3/../../../arm-none-eabi/bin/ld: cannot find -lg
makefile:42: recipe for target 'imx6-A9.elf' failed
/usr/lib/gcc/arm-none-eabi/4.9.3/../../../arm-none-eabi/bin/ld: cannot find -lc
collect2: error: ld returned 1 exit status
make: *** [imx6-A9.elf] Error 1
Which I haven't been able to resolve.
I don't know if this error is a consequence of the way I solved the two previous errors.
Does anybody know how to properly setup eclipse for i.MX6 bare-metal development?
Thank you very much for helping!!
If you want to develop bare-metal code for the i.MX6SoloX without using CodeSourcery then you need to execute this:
sudo apt-get install gcc-arm-none-eabi libnewlib-arm-none-eabi -y
And then choose "Custom (arm-none-eabi-gcc)" at Project>Settings>C/C++ Build in the 'Toolchains' tab.

Swift compile error: "cannot load underlying module for 'CoreGraphics'" with `import Foundation`

With Swift DEVELOPMENT-SNAPSHOT-2016-02-08-a, I'm trying to build a project using swift build but as soon as I add the line import Foundation I get the error:
[I] ~/Dropbox/Projects/test
↪ swift build --clean; and swift build
Compiling Swift Module 'test' (1 sources)
<unknown>:0: error: cannot load underlying module for 'CoreGraphics'
<unknown>:0: note: did you forget to set an SDK using -sdk or SDKROOT?
<unknown>:0: note: use "xcrun -sdk macosx swiftc" to select the default OS X SDK installed with Xcode
<unknown>:0: error: build had 1 command failures
error: exit(1): ["/Library/Developer/Toolchains/swift-DEVELOPMENT-SNAPSHOT-2016-02-08-a.xctoolchain/usr/bin/swift-build-tool", "-f", "/Users/me/Dropbox/Projects/test/.build/debug/test.o/llbuild.yaml"]
Running xcrun -sdk macosx results in "no such SDK: 'machos'" error:
↪ xcrun -sdk macosx swift build 0#10:34:03
<unknown>:0: warning: no such SDK: 'macosx'
<unknown>:0: warning: no such sysroot directory: 'macosx'
<unknown>:0: error: cannot load underlying module for 'Darwin'
error: exit(1): ["/Library/Developer/Toolchains/swift-DEVELOPMENT-SNAPSHOT-2016-02-08-a.xctoolchain/usr/bin/swiftc", "--driver-mode=swift", "-I", "/Library/Developer/Toolchains/swift-DEVELOPMENT-SNAPSHOT-2016-02-08-a.xctoolchain/usr/lib/swift/pm", "-L", "/Library/Developer/Toolchains/swift-DEVELOPMENT-SNAPSHOT-2016-02-08-a.xctoolchain/usr/lib/swift/pm", "-lPackageDescription", "-target", "x86_64-apple-macosx10.10", "/Users/me/Dropbox/Projects/test/Package.swift"]
This is with only main.swift, whose contents are:
import Foundation
print("Hello, world!")
No dependencies are defined in Packages.swift.
Really don't know what's going on here. This compiles fine on my Ubuntu 14.04 DigitalOcean VPS as well as within Xcode 7.3 Beta 5.
OS X 10.11.3
↪ swift --version 0#10:21:16
Apple Swift version 3.0-dev (LLVM a7663bb722, Clang 4ca3c7fa28, Swift 1c2f40e246)
Target: x86_64-apple-macosx10.9
Do you have the stable release of Xcode.app in your [/Applications] directory? If you just have Xcode-beta.app, that's likely what's causing this error. Try creating a symlink of Xcode-beta.app to Xcode.app:
$ ln -s /Applications/Xcode-beta.app /Applications/Xcode.app
(Kudos to anton for the answer).