What targets are available for the swiftc -target and -target-cpu option? - swift

this question is about cross compilation.
What kind of different targets are available using the -target or -target-cpu option of the swift compiler?
Where can I find an overview?
Is it only there to create iOS/watchOS apps or can I use it to create linux programs (regular x86-64 processor) on macOS?
I tried searching the github repository and found 'x86_64-unknown-linux-gnu' as a target. However when I try to compile a simple "hello world" program (swiftc -target x86_64-unknown-linux-gnu test.swift) I get this error:
<unknown>:0: error: unable to load standard library for target 'x86_64-unknown-linux-gnu'
Edit:
I agree with CristiFati. The last part of this question is rather about how to properly include/reference the glibc (?!?).

If you look at Swift repository on Github (Exact location: swift/utils/swift_build_support/swift_build_support/targets.py) You will see all host targets at line 149-192 in target.py.
Supports:
def host_target():
"""
Return the host target for the build machine, if it is one of
the recognized targets. Otherwise, throw a NotImplementedError.
"""
system = platform.system()
machine = platform.machine()
if system == 'Linux':
if machine == 'x86_64':
return StdlibDeploymentTarget.Linux.x86_64
elif machine.startswith('armv7'):
# linux-armv7* is canonicalized to 'linux-armv7'
return StdlibDeploymentTarget.Linux.armv7
elif machine.startswith('armv6'):
# linux-armv6* is canonicalized to 'linux-armv6'
return StdlibDeploymentTarget.Linux.armv6
elif machine == 'aarch64':
return StdlibDeploymentTarget.Linux.aarch64
elif machine == 'ppc64':
return StdlibDeploymentTarget.Linux.powerpc64
elif machine == 'ppc64le':
return StdlibDeploymentTarget.Linux.powerpc64le
elif machine == 's390x':
return StdlibDeploymentTarget.Linux.s390x
elif system == 'Darwin':
if machine == 'x86_64':
return StdlibDeploymentTarget.OSX.x86_64
elif system == 'FreeBSD':
if machine == 'amd64':
return StdlibDeploymentTarget.FreeBSD.x86_64
elif system == 'CYGWIN_NT-10.0':
if machine == 'x86_64':
return StdlibDeploymentTarget.Cygwin.x86_64
elif system == 'Windows':
if machine == "AMD64":
return StdlibDeploymentTarget.Windows.x86_64
raise NotImplementedError('System "%s" with architecture "%s" is not '
'supported' % (system, machine))

Related

Changing version and build number for a specific target Fastlane

I am trying to implement Fastlane into a Xcode project containing over 30 apps.
At this moment I am stuck with the lane that builds the app for the "AppStore" as it has to change the version and the build number for a specific target. The code for my lane is:
desc "Archives and creates the app for the AppStore"
lane :build_appstore do |options|
scheme = options[:scheme]
output_directory = options[:output_directory]
configuration = options[:configuration]
export_method = options[:export_method]
bundle_id = options[:bundle_id]
version = options[:version]
build = options[:build]
# Used for increment_version_number. Does it work?
ENV["APP_IDENTIFIER"] = options[:bundle_id]
increment_version_number(
version_number: version
)
increment_build_number(
build_number: build
)
gym(
scheme: scheme,
output_directory: output_directory,
configuration: configuration,
export_method: export_method
)
end
The lanes works but when I have a look at the project, I see that all targets have the version and build number changed which is a little but of inconvenient.
Any ideas??
I ended up create using xcodeproj ruby and I create the following lane:
# Sets the "VERSION" and "BUILD" number for a target
#
# #param args [Hash] Key value arguments. All the values are Strings. List:
# - target_name: The name of the target (REQUIRED)
# - version: The version number to be used (REQUIRED)
# - build: The build number to be used (REQUIRED)
#
desc "Sets the \"VERSION\" and \"BUILD\" number for a target"
lane :set_version_build_number do |args|
puts("\"set_version_build_number\" lane with ARGUMENTS: #{args}")
target_name = args[:target_name]
version = args[:version]
build = args[:build]
raise(StandardError, "Invalid ARGUMENTS for: \"set_version_build_number\" LANE") unless (
target_name != nil &&
version != nil &&
build != nil
)
puts("Variables:")
puts("\ttarget_name: #{target_name}")
puts("\tversion: #{version}")
puts("\tbuild: #{build}")
project_url = find_xcode_project()
raise(StandardError, "Invalid Xcode project for: \"set_version_build_number\" LANE") unless project_url != nil
project = Xcodeproj::Project.open(project_url)
xc_target = project.targets.find { |target| target.name == target_name }
raise(StandardError, "Invalid target for: \"set_version_build_number\" LANE") unless xc_target != nil
xc_target.build_configurations.each { |build_configuration|
build_configuration.build_settings["MARKETING_VERSION"] = version
build_configuration.build_settings["CURRENT_PROJECT_VERSION"] = build
}
project.save()
end

Enterprise Architect - Import relations

I have a model in Enterprise Architect and I need to import some relationships (of already existing elements) that I have in an Excel. I tried running a JScript but wasn't able to run it (haven't still figured out why).
How can I import a massive amount of relationship into my model?
Thanks in advance.
My Script is:
!INC Local Scripts.EAConstants-JScript
var connectorArray = new Array(
['{870632BA-154F-4564-AD51-C508C1A7E537}','{4B291196-7B4B-490b-B51D-04B9925CAA2A}','Dependency','','RME1']
);
function main()
{
var source as EA.Element;
var target as EA.Element;
var connector as EA.Connector;
var sourceGUID,targetGUID,type,stereotype,alias;
for(var i = 0; i < connectorArray.length; i++) {
sourceGUID = connectorArray[i][0];
targetGUID = connectorArray[i][1];
type = connectorArray[i][2];
stereotype = connectorArray[i][3];
alias = connectorArray[i][4];
source = Repository.GetElementByGuid(sourceGUID);
target = Repository.GetElementByGuid(targetGUID);
Session.Output("Processing connector: " + alias);
if(source != null && target != null) {
connector = source.Connectors.AddNew("",type);
if(stereotype != "") {
connector.Stereotype = stereotype;
}
connector.SupplierID = target.ElementID;
connector.Alias = alias;
connector.Update();
}
source.Connectors.Refresh();
}
Session.Output("END OF SCRIPT");
}
main();
My errors are:
[423447640] Hilo de registro de pila establecido para marcos 3
[423447879] Default Directory is C:\Program Files (x86)\Sparx Systems\EA
[423447879] Agent dll found: C:\Program Files (x86)\Sparx Systems\EA\vea\x86\SSScriptAgent32.DLL
[423447879] Default Directory is C:\Program Files (x86)\Sparx Systems\EA
[423447879] Agent: Started
[423447967] Microsoft Process Debug Manager creation Failed: 0x80040154
[423447967] This is included as part of various Microsoft products.
[423447967] Download the Microsoft Script Debugger to install it.
[423447967] Failed to initialize JScript engine
[423447967] SesiĆ³n de depuraciĆ³n terminada
Thanks again.
Well, may be I'm wrong, but you can see the error Download the Microsoft Script Debugger to install it. I guess, that you're trying to run the script "Debug" button instead of "Run script".
If you want to debug your scrtipt, you"ll must to install any Microsoft product that contains debagger. Microsoft Script Debugger.
FYI Did you try the Excel Import \ Export feature of Sparx Systems in MDG Office Integration .
You can create \ update \ Synchronise model elements, connectors and other details inside enterprise architect in a single click.

Adding support for 32-bit Ubuntu to Swift

I'm trying to build Swift from source on a 32-bit Ubuntu virtual machine.
I've done the following modifications, mostly in the build scripts:
(see https://pastebin.com/rmWecTu7)
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 112b5d6..16db3ba 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
## -538,12 +538,16 ##
endif()
endif()
+message(STATUS ">>> CMAKE_SYSTEM_PROCESSOR: " ${CMAKE_SYSTEM_PROCESSOR})
+
# If SWIFT_HOST_VARIANT_ARCH not given, try to detect from the CMAKE_SYSTEM_PROCESSOR.
if(SWIFT_HOST_VARIANT_ARCH)
set(SWIFT_HOST_VARIANT_ARCH_default, "${SWIFT_HOST_VARIANT_ARCH}")
else()
if("${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "x86_64")
set(SWIFT_HOST_VARIANT_ARCH_default "x86_64")
+ elseif("${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "i686")
+ set(SWIFT_HOST_VARIANT_ARCH_default "i686")
elseif("${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "aarch64")
set(SWIFT_HOST_VARIANT_ARCH_default "aarch64")
elseif("${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "ppc64")
## -613,10 +617,14 ##
set(SWIFT_HOST_VARIANT "linux" CACHE STRING
"Deployment OS for Swift host tools (the compiler) [linux].")
+ message(STATUS ">>> SWIFT_HOST_VARIANT_ARCH: " ${SWIFT_HOST_VARIANT_ARCH})
+
# Calculate the host triple
if("${SWIFT_HOST_TRIPLE}" STREQUAL "")
if("${SWIFT_HOST_VARIANT_ARCH}" STREQUAL "x86_64")
set(SWIFT_HOST_TRIPLE "x86_64-unknown-linux-gnu")
+ elseif("${SWIFT_HOST_VARIANT_ARCH}" STREQUAL "i686")
+ set(SWIFT_HOST_TRIPLE "i686-unknown-linux-gnu")
elseif("${SWIFT_HOST_VARIANT_ARCH}" STREQUAL "aarch64")
set(SWIFT_HOST_TRIPLE "aarch64-unknown-linux-gnu")
elseif("${SWIFT_HOST_VARIANT_ARCH}" MATCHES "(powerpc64|powerpc64le)")
diff --git a/stdlib/public/SwiftShims/LibcShims.h b/stdlib/public/SwiftShims/LibcShims.h
index e726a62..5fd7826 100644
--- a/stdlib/public/SwiftShims/LibcShims.h
+++ b/stdlib/public/SwiftShims/LibcShims.h
## -33,7 +33,9 ##
// This declaration is not universally correct. We verify its correctness for
// the current platform in the runtime code.
-#if defined(__linux__) && defined (__arm__)
+#if defined(__linux__) && defined(__arm__)
+typedef int __swift_ssize_t;
+#elif defined(__linux__) && defined(__i386__)
typedef int __swift_ssize_t;
#elif defined(_WIN32)
#if defined(_M_ARM) || defined(_M_IX86)
diff --git a/utils/build-script-impl b/utils/build-script-impl
index 1bfbcc5..b058b22 100755
--- a/utils/build-script-impl
+++ b/utils/build-script-impl
## -449,6 +449,9 ##
--$(tolower "${PLAYGROUNDLOGGER_BUILD_TYPE}")
)
;;
+ linux-i686)
+ SWIFT_HOST_VARIANT_ARCH="i686"
+ ;;
linux-armv6)
SWIFT_HOST_VARIANT_ARCH="armv6"
SWIFT_HOST_TRIPLE="armv6-unknown-linux-gnueabihf"
diff --git a/utils/swift_build_support/swift_build_support/targets.py b/utils/swift_build_support/swift_build_support/targets.py
index f4b5bb0..690a3d3 100644
--- a/utils/swift_build_support/swift_build_support/targets.py
+++ b/utils/swift_build_support/swift_build_support/targets.py
## -112,6 +112,7 ##
is_simulator=True)
Linux = Platform("linux", archs=[
+ "i686",
"x86_64",
"armv6",
"armv7",
## -174,6 +175,8 ##
return StdlibDeploymentTarget.Linux.powerpc64le
elif machine == 's390x':
return StdlibDeploymentTarget.Linux.s390x
+ elif machine == 'i686':
+ return StdlibDeploymentTarget.Linux.i686
elif system == 'Darwin':
if machine == 'x86_64':
Build fails when trying to build stdlib, giving some error related to Float80: (see https://pastebin.com/ue8MRquU)
swift: /home/gigi/local/Source/apple/swift/lib/IRGen/StructLayout.cpp:357: void swift::irgen::StructLayoutBuilder::setAsBodyOfStruct(llvm::StructType *) const: Assertion `(!isFixedLayout() || IGM.DataLayout.getStructLayout(type)->getSizeInBytes() == CurSize.getValue()) && "LLVM size of fixed struct type does not match StructLayout size"' failed.
/home/gigi/local/Source/apple/build/Ninja-ReleaseAssert/swift-linux-i686/bin/swift[0xc335ea0]
Stack dump:
0. Program arguments: /home/gigi/local/Source/apple/build/Ninja-ReleaseAssert/swift-linux-i686/bin/swift -frontend -c -filelist /tmp/sources-628097 -disable-objc-attr-requires-foundation-module -target i686-unknown-linux-gnu -disable-objc-interop -sdk / -I /home/gigi/local/Source/apple/build/Ninja-ReleaseAssert/swift-linux-i686/./lib/swift/linux/i686 -warn-swift3-objc-inference-complete -module-cache-path /home/gigi/local/Source/apple/build/Ninja-ReleaseAssert/swift-linux-i686/./module-cache -module-link-name swiftCore -nostdimport -parse-stdlib -resource-dir /home/gigi/local/Source/apple/build/Ninja-ReleaseAssert/swift-linux-i686/./lib/swift -swift-version 3 -O -D INTERNAL_CHECKS_ENABLED -group-info-path /home/gigi/local/Source/apple/swift/stdlib/public/core/GroupInfo.json -enable-sil-ownership -Xllvm -sil-inline-generics -Xllvm -sil-partial-specialization -Xcc -D__SWIFT_CURRENT_DYLIB=swiftCore -parse-as-library -module-name Swift -o /home/gigi/local/Source/apple/build/Ninja-ReleaseAssert/swift-linux-i686/stdlib/public/core/linux/i686/Swift.o
1. While running pass #147 SILFunctionTransform "SIL alloc_stack Hoisting" on SILFunction "#_T0s7Float80V15_representationAB01_A14RepresentationVvg".
for getter for _representation at /home/gigi/local/Source/apple/swift/stdlib/public/core/FloatingPointTypes.swift.gyb:342:16
2. While converting type 'Float80' (declared at [/home/gigi/local/Source/apple/swift/stdlib/public/core/FloatingPointTypes.swift.gyb:74:8 - line:3662:1] RangeText="struct Float80 {
public // #testable
var _value: Builtin.FPIEEE80
/// Creates a value initialized to zero.
#_inlineable // FIXME(sil-serialize-all)
#_transparent
public init() {
let zero: Int64 = 0
self._value = Builtin.sitofp_Int64_FPIEEE80(zero._value)
}
#_inlineable // FIXME(sil-serialize-all)
#_transparent
public // #testable
init(_bits v: Builtin.FPIEEE80) {
self._value = v
}
}")
<unknown>:0: error: unable to execute command: Aborted
<unknown>:0: error: compile command failed due to signal 6 (use -v to see invocation)
ninja: build stopped: subcommand failed.
/home/gigi/local/Source/apple/swift/utils/build-script: fatal error: command terminated with a non-zero exit status 1, aborting
gigi#gigi-VirtualBox:~$ ]
Using ~/local/Source/apple/swift/utils/build-script --release to build.
I'm guessing the error has to do with this modification:
#elif defined(__linux__) && defined(__i386__)
typedef int __swift_ssize_t;
The official Swift project does not support 32bit architecture yet. There is an official ticket: Port Swift to Linux x86 32-bit
You will have more chance to get support on this ticket if you want to add this port yourself.

environment variables using subprocess.check_output Python

I'm trying to do some basic module setups on my server using Python. Its a bit difficult as I have no access to the internet.
This is my code
import sys
import os
from subprocess import CalledProcessError, STDOUT, check_output
def run_in_path(command, dir_path, env_var=''):
env_var = os.environ["PATH"] = os.environ["PATH"] + env_var
print(env_var)
try:
p = check_output(command, cwd=dir_path, stderr=STDOUT)
except CalledProcessError as e:
sys.stderr.write(e.output.decode("utf-8"))
sys.stderr.flush()
return e.returncode
else:
return 0
def main():
requests_install = run_in_path('python setup.py build',
'D:\installed_software\python modules\kennethreitz-requests-e95e173')
SQL_install = run_in_path('python setup.py install', # install SQL module pypyodbc
'D:\installed_software\python modules\pypyodbc-1.3.3\pypyodbc-1.3.3')
setup_tools = run_in_path('python setup.py install', # install setup tools
'D:\installed_software\python modules\setuptools-17.1.1')
psycopg2 = run_in_path('easy_install psycopg2-2.6.1.win-amd64-py3.3-pg9.4.4-release', # install setup tools
'D:\installed_software\python modules', ';C:\srv_apps\Python33\Scripts\easy_install.exe')
print('setup complete')
if __name__ == "__main__":
sys.exit(main())
now it gets tricky when i start trying to use easy install. It appears my env variables are not being used by my subprocess.check_output call
File "C:\srv_apps\Python33\lib\subprocess.py", line 1110, in _execute_child
raise WindowsError(*e.args)
FileNotFoundError: [WinError 2] The system cannot find the file specified
I don't want to have to upgrade to 3.4 where easy install is installed by default because my other modules are not supported on 3.4. My main challenge is the subprocess.check_call method does not take environment variables as an input and im wary of trying to use Popen() as I have never really got it to work successfully in the past. Any help would be greatly appreciated.
PATH should contain directories e.g., r'C:\Python33\Scripts', not files such as: r'C:\Python33\Scripts\easy_install.exe'
Don't hardcode utf-8 for an arbitrary command, you could enable text mode using universal_newlines parameter (not tested):
#!/usr/bin/env python3
import locale
import sys
from subprocess import CalledProcessError, STDOUT, check_output
def run(command, *, cwd=None, env=None):
try:
ignored = check_output(command, cwd=cwd, env=env,
stderr=STDOUT,
universal_newlines=True)
except CalledProcessError as e:
sys.stderr.write(e.output)
sys.stderr.flush()
return e.returncode
else:
return 0
Example:
import os
path_var = os.pathsep.join(os.environ.get('PATH', os.defpath), some_dir)
env = dict(os.environ, PATH=path_var)
run("some_command", cwd=some_path, env=env)
run("another_command", cwd=another_path, env=env)

gmake: a target completes but $(realpath ...) doesn't find it

Environment stuff:
Solaris NFS file servers running NFS 3
Errors occur in Linux or Solaris environments
Using GNU Make 3.82
Using Sun Studio compilers, if that matters
This is a vastly simplified example of the build I'm looking at:
all: ${list of shared objects to build}
#do whatever
lib1.so: ${1s objects}
lib2.so: ${2s objects}
lib3.so: ${3s objects}
#...
%.so:
$(call CHECK_DEPENDENCIES_EXIST)
#${LD} ${LDFLAGS} ${^} -o ${#}
%.o : %.c
#do stuff
%.o : %.cc
#do stuff
define CHECK_DEPENDENCIES_EXIST =
$(if $(realpath ${^}),,$(warning No dependencies specified for ${#})false)
endef
The short & sweet: $(realpath x y z) (x/y/z get returned if they exist; returns an absolute path including no symlinks) is removing files from the list under some circumstances, and I think it has to do with NFS. It isn't predictable which target will fail. Sometimes a target will fail when it's succeeded the last 10 times. If I take #false out of the macro, the build continues without error -- that is, the linker does not complain about the supposedly missing file(s).
I'll spare you the drawn-out explanation; suffice it to say, the macro is helpful for debugging.
Turns out there's a bug in gmake. From the GNU Make 3.82 source, function.c, on or about line 2026:
while ((path = find_next_token (&p, &len)) != 0 ) {
/* ... */
if (
#ifdef HAVE_REALPATH
realpath (in, out)
#else
abspath (in, out) && stat (out, &st) == 0
#endif
)
{
/* ... */
}
}
}
/* ... */
Ocasionally, various calls to realpath would get interrupted (EINTR); nothing in this code checks errno, so it just silently fails.
So, it wasn't that the file didn't exist, it was that $(realpath ...) was being interrupted by a signal (presumably a child instance of gmake signaling its completion or something similar) and this function wasn't designed to recover from that sort of event.
To fix the problem:
while ((path = find_next_token (&p, &len)) != 0 ) {
... becomes:
while ( errno == EINTR || (path = find_next_token (&p, &len)) != 0 ) {
The || will shortcut & prevent it from marching on to the next token.