Compiler

RSS for tag

Discuss the various compiler and toolchain technologies used in development.

Posts under Compiler tag

112 Posts
Sort by:

Post

Replies

Boosts

Views

Activity

How to disable the "Do you want the application XY to accept incoming network connections?"
I am developing a piece of software with OpenMPI and every time I recompile the program, I am prompted to click Allow/Deny the connections in N pop-ups (where N is the number of spawned processors by MPI). Is there any way to completely disable the pop-ups? When I allow or deny the access for one particular binary, the pop-ups do not show in successive runs. However, after recompiling a new one, the issue persists. Turning off the firewall does not help, neither does allowing/blocking incoming connections in the Firewall settings (Settings -> Firewall -> Options). I am open to any hacky solution or a workaround as this is really annoying and deteriorates my workflow.
1
0
454
Feb ’24
Can't compile code with __MAC_OS_X_VERSION_MIN_REQUIRED undefined
I've been using a code that pass -U__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ during compilation. The code was compiling well for a while. I haven't been using that project for a while, but recently found out that my project start failing to build with errors: In file included from my_project/main_app.cpp:52: In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/mach/mach_time.h:32: In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/mach/mach_types.h:109: In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/mach/vm_region.h:47: In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/mach/machine/vm_param.h:33: In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/mach/i386/vm_param.h:97: /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/mach/vm_page_size.h:59:44: error: expected ';' after top level declarator extern vm_size_t vm_kernel_page_size __OSX_AVAILABLE_STARTING(__MAC_10_9, __IPHONE_7_0); My /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/Availability.h file contains #ifdef __IPHONE_OS_VERSION_MIN_REQUIRED ... #elif defined(__MAC_OS_X_VERSION_MIN_REQUIRED) ... #else #define __OSX_AVAILABLE_STARTING(_osx, _ios) #define __OSX_AVAILABLE_BUT_DEPRECATED(_osxIntro, _osxDep, _iosIntro, _iosDep) #define __OSX_AVAILABLE_BUT_DEPRECATED_MSG(_osxIntro, _osxDep, _iosIntro, _iosDep, _msg) #endif but the last #else case is never hit because /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/AvailabilityInternal.h contains: #ifndef __MAC_OS_X_VERSION_MIN_REQUIRED #if defined(__has_builtin) && __has_builtin(__is_target_os) #if __is_target_os(macos) #define __MAC_OS_X_VERSION_MIN_REQUIRED __ENVIRONMENT_OS_VERSION_MIN_REQUIRED__ #define __MAC_OS_X_VERSION_MAX_ALLOWED __MAC_14_2 #endif #elif __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ #define __MAC_OS_X_VERSION_MIN_REQUIRED __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ #define __MAC_OS_X_VERSION_MAX_ALLOWED __MAC_14_2 #endif /* __has_builtin(__is_target_os) && __is_target_os(macos) */ #endif /* __MAC_OS_X_VERSION_MIN_REQUIRED */ So in combination with my initial -U__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ option the #define __MAC_OS_X_VERSION_MIN_REQUIRED __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ produce an empty define. So the question to apple developers: could you please update #elif __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ to #elif defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__)? Or even change #ifndef __MAC_OS_X_VERSION_MIN_REQUIRED to #if !defined(__MAC_OS_X_VERSION_MIN_REQUIRED) && defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__)? Otherwise the #else case in Availability.h described above does not make any sense. Best regards, Petro
1
0
551
Feb ’24
Passing Swift String type to a Cpp function in the new interop
I have implemented the new cpp-swift interop mechanism using modulemap file. I have a use case to pass a swift string to the cpp function. I observed that the below code works and I am able to pass a swift String type directly to a cpp function which received it as const char *. This works only if its received as const char * in cpp(and not char *). However, this is not an interop documented behaviour for interoperating String types and wanted to know whether this is safe to use. If not, can someone suggest an alternative approach to pass a swift string to Cpp. // Swift code public static func StringToCharPointer () -> Void { // calling cpp function and passing a swift String type as argument, which is received as const char * Student.Convert (sUItextdata) //sUItextdata is of type 'String' } //static Cpp function void Student::Convert (const char * pStr) { std::string s(pStr); std::cout << "char * converted from swift String : " << s << std::endl; } Note : I am aware that there is a way to pass it to cpp and receive it as std:string, but I do not wish to use that.
1
0
462
Feb ’24
openCV can work with GPU
Hello, I am a new user with an Apple MacBook Pro. I'm experiencing difficulties running my code through the GPU. What do I need to install on my computer to be able to use libraries for machine learning, Computer Vision, PyTorch and Tensor Flow? I already watch lot of tutorials on this subject, but still is looks very complicated and I need mentoring for this task. I would greatly appreciate it if I could receive a response and if someone could guide me on this matter.
0
0
638
Feb ’24
Swift extension method not accessible in Cpp using interop
I have a project implementing new interop mechanism and I m able to successfully invoke swift class method directly from swift. However, when I try to invoke the swift extension method it produces an error : No member named 'GetExtData' in 'InteropExtension::SwiftCode' Below is my cpp code: #include "CppSource.hpp" #include "InteropExtension-Swift.h" void CppSource::CppToSwiftCall() { // successfull call InteropExtension::SwiftCode::GetClassData(); //Below call is causing error. Why is swift extension method not invoked? InteropExtension::SwiftCode::GetExtData(); } Below is my swift code: import Foundation public class SwiftCode { public static func GetClassData () -> String { return "classMethod" } } extension SwiftCode { public static func GetExtData () -> String { return "ExtMethod" } } Can someone helpout on why is the extension methods not being invoked, and how can I invoke it?
1
2
436
Feb ’24
Segmented Fault 11: error (Xcode 15)
I'm encountering an **error Segmentation fault: 11 ** during the archiving process. If the issue is happing with the my code. Then how can I diagnosing the problem. or figure out pin point in code base? I changed the compiler optimization level. It works for me when I use the Osize compiler optimization level. Previously, it was set to Ospeed. Want to know about the impact of the Osize compiler optimization level on the app.
3
1
610
Feb ’24
How to solve the problem of "-macosx_version_min has been renamed to -macos_version_min"?
I am now using the fortran compiler to compile the codes with the command of "make -f Makefile". In the previous time, the command: make -f Makefile works well, but after updating the MacOS system, the same command results in the following error: -macosx_version_min has been renamed to -macos_version_min ld: unknown options: -commons collect2: error:ld returns 1 Is there anyone know how to solve the above problem? Thanks a lot for your time and help.
1
0
562
Feb ’24
Generating .App file for Swift Macros fails
We are having a setup , where we generates .app file from our iOS project using this command xcodebuild -scheme MyApp -project ./MyApp.xcodeproj -configuration Release\ (Development) -derivedDataPath build/derived_data -destination 'generic/platform=iOS' -archivePath build/MyApp.xcarchive archive which is work fine. but we have a new library that uses new swift Macros, that we can’t anymore use this command without errors. so we switched to -destination 'platform=iOS Simulator,name=iPhone' now it compile fine. but when adding the .app file to simulator , it just crash the app. is there a better way to generate such file that can work on simulator without try to enforce x86_64. cause it seems that macros are not supporting that.
0
0
409
Feb ’24
Extremely slow compilation and build times in terminal
Hi, I'm having problems with extremely build and compilation of software in the command line and I'm not sure why. I'm currently using macOS Sonoma 14.3 on my 2020 MacBook Air 1.1 GHz Quad-Core Intel Core i5. I also have the latest version of Xcode installed. Although I've been experiencing extreme delays in the command line for a while, the problem really became noticeable after I updated my OS to Sonoma. It meant that all the software I had installed via command line that I regularly use became outdated and now I cannot build it again. I've spoken in depth with the authors of the software and they have tried on a system identical to mine and have a build time of 30 minutes, but my machine takes over 3 hours on the same software. I've uninstalled and reinstalled command line tools several times but nothing seems to work. Also when I build I use the command make -j7 to use 7/8 cores so the problem isn't that I'm making full use of my CPU either. I've spoken to Apple support who recommended I try in Safe Mode and using a different user to rule out background software that opens on start up and decreases performance, as well as to rule out the setup on my main user. I'm just not sure what to do anymore as I've been trying for days and to no avail. Does anyone have any suggestions? P.S. It may be irrelevant, but since Sonoma I've also been experiencing a lot of issues with clang and also SDK pathways.
0
0
558
Jan ’24
Converting 'String' Type in swift to 'const char *' in cpp
I have the below code where my swift code calls a cpp function. In this the swift calls a cpp function and passes a swift 'String' as argument to it, which is then received in the cpp code as 'const char *'. This conversion works without any errors. Is this a documented behaviour in cpp-swift interop and is this safe to use? Swift side: internal static func CharCheck (pSentence: String) -> Void { TWSoundLogic.CharacterSoundCount (pSentence) } In the C++ side, void TWSoundLogic::CharacterSoundCount (const char * pSentence) { .. } However, on returning a String type from a swift function and trying to receive it as a const char* in c++, it gives an error in cpp No viable conversion from 'swift::String' to 'const char *' . Why does it not allow to return, but it allows to pass as argument? Can someone explain this behaviour?
0
1
406
Jan ’24
My App build and run on actual device and simulator but fails to archive
Hello everyone! I'm quite new to App development (but have quite a bit of programming experience). I have reached the point where I would like to Archive my app for release but I'm stumped at an issue where the app compiles, builds and runs just fine in XCode on device and simulator targets however fails when I want to archive the app. My app ends up using a mix of a lot of things possible: Swift and SwiftUI Obj-C and some vanilla C, mainly because I use a framework in C Very minimal but some UIKit (that bridges with some parts in C) Here is the stacktrace, would appreciate some insights 1. Apple Swift version 5.9.2 (swiftlang-5.9.2.2.56 clang-1500.1.0.2.5) 2. Compiling with the current language version 3. While evaluating request ExecuteSILPipelineRequest(Run pipelines { PrepareOptimizationPasses, EarlyModulePasses, HighLevel,Function+EarlyLoopOpt, HighLevel,Module+StackPromote, MidLevel,Function, ClosureSpecialize, LowLevel,Function, LateLoopOpt, SIL Debug Info Generator } on SIL for CamHero) 4. While running pass #12497 SILModuleTransform "PerformanceSILLinker". 5. While deserializing SIL function "$s7SwiftUI11EnvironmentV12wrappedValuexvg" 6. While deserializing SIL function "os_log_type_enabled" 7. *** DESERIALIZATION FAILURE *** *** If any module named here was modified in the SDK, please delete the *** *** new swiftmodule files from the SDK and keep only swiftinterfaces. *** module 'SwiftUI', builder version '5.9.2(5.9.2)/Apple Swift version 5.9.2 (swiftlang-5.9.2.2.56 clang-1500.1.0.2.5)', built from swiftinterface, resilient, loaded from '/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphoneos/prebuilt-modules/17.2/SwiftUI.swiftmodule/arm64-apple-ios.swiftmodule' result not found (isEnabled) Cross-reference to module 'os' ... OSLog ... in an extension in module 'os' ... isEnabled ... with type (OSLog) -> (OSLogType) -> Bool Stack dump without symbol names (ensure you have llvm-symbolizer in your PATH or set the environment var `LLVM_SYMBOLIZER_PATH` to point to it): 0 swift-frontend 0x0000000103a11abc llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) + 56 1 swift-frontend 0x0000000106677cb0 llvm::sys::RunSignalHandlers() + 112 2 swift-frontend 0x00000001063e1054 SignalHandler(int) + 352 3 libsystem_platform.dylib 0x00000001895b3a24 _sigtramp + 56 4 libsystem_pthread.dylib 0x0000000189584cc0 pthread_kill + 288 5 libsystem_c.dylib 0x0000000189494a40 abort + 180 6 swift-frontend 0x0000000102bd7c2c (anonymous namespace)::ParsedAttrInfoFallThrough::~ParsedAttrInfoFallThrough() + 0 7 swift-frontend 0x0000000104470db8 std::__1::__function::__func<swift::evaluator::PerRequestReferences swift::evaluator::PerRequestReferences::makeEmpty<swift::LookupPrefixOperatorRequest>()::'lambda'(void*), std::__1::allocator<swift::evaluator::PerRequestReferences swift::evaluator::PerRequestReferences::makeEmpty<swift::LookupPrefixOperatorRequest>()::'lambda'(void*)>, void (void*)>::operator()(void*&&) + 0 8 swift-frontend 0x0000000102b2c534 swift::ModuleFile::fatal(llvm::Error) const + 44 9 swift-frontend 0x00000001044721dc swift::CyclicalRequestError<swift::LookupPrefixOperatorRequest>::~CyclicalRequestError() + 0 10 swift-frontend 0x00000001045bb880 swift::SILDeserializer::readSILFunctionChecked(llvm::PointerEmbeddedInt<unsigned int, 31>, swift::SILFunction*, llvm::StringRef, bool, bool) + 1588 11 swift-frontend 0x0000000102bb0f50 swift::SILDeserializer::getFuncForReference(llvm::StringRef, swift::SILType) + 504 12 swift-frontend 0x00000001045cb578 swift::SILDeserializer::readSILInstruction(swift::SILFunction*, swift::SILBuilder&, unsigned int, llvm::SmallVectorImpl<unsigned long long>&) + 29524 13 swift-frontend 0x00000001045bc554 swift::SILDeserializer::readSILFunctionChecked(llvm::PointerEmbeddedInt<unsigned int, 31>, swift::SILFunction*, llvm::StringRef, bool, bool) + 4872 14 swift-frontend 0x00000001045d6934 swift::SILDeserializer::lookupSILFunction(swift::SILFunction*, bool) + 636 15 swift-frontend 0x0000000102c4d990 swift::SILLinkerVisitor::deserializeAndPushToWorklist(swift::SILFunction*) + 88 16 swift-frontend 0x0000000102c4dfb0 swift::SILLinkerVisitor::processFunction(swift::SILFunction*) + 248 17 swift-frontend 0x0000000103c60fa4 (anonymous namespace)::SILLinker::run() (.llvm.15023899450236721039) + 136 18 swift-frontend 0x0000000106018874 swift::SILPassManager::executePassPipelinePlan(swift::SILPassPipelinePlan const&) + 16276 19 swift-frontend 0x00000001061c21c4 swift::SimpleRequest<swift::ExecuteSILPipelineRequest, std::__1::tuple<> (swift::SILPipelineExecutionDescriptor), (swift::RequestFlags)1>::evaluateRequest(swift::ExecuteSILPipelineRequest const&, swift::Evaluator&) + 56 20 swift-frontend 0x00000001060646b8 llvm::Expected<swift::ExecuteSILPipelineRequest::OutputType> swift::Evaluator::getResultUncached<swift::ExecuteSILPipelineRequest>(swift::ExecuteSILPipelineRequest const&) + 476 21 swift-frontend 0x000000010607c424 swift::runSILOptimizationPasses(swift::SILModule&) + 472 22 swift-frontend 0x000000010400c3c0 swift::CompilerInstance::performSILProcessing(swift::SILModule*) + 572 23 swift-frontend 0x0000000105f59454 performCompileStepsPostSILGen(swift::CompilerInstance&, std::__1::unique_ptr<swift::SILModule, std::__1::default_delete<swift::SILModule>>, llvm::PointerUnion<swift::ModuleDecl*, swift::SourceFile*>, swift::PrimarySpecificPaths const&, int&, swift::FrontendObserver*) + 956 24 swift-frontend 0x0000000105f54f00 performCompile(swift::CompilerInstance&, int&, swift::FrontendObserver*) + 3020 25 swift-frontend 0x0000000105f58854 swift::performFrontend(llvm::ArrayRef<char const*>, char const*, void*, swift::FrontendObserver*) + 4568 26 swift-frontend 0x0000000105fbfd44 swift::mainEntry(int, char const**) + 4408 27 dyld 0x00000001892090e0 start + 2360 Command SwiftCompile failed with a nonzero exit code
3
0
791
Jan ’24
Can you still define a struct in Assembly?
Using Xcode 15.2, x86_64, and for the life of me, I can't figure out how to declare a data structure in assembly. All the "current"ish references I've read for Clang LLVM & "as" assembly have no references to data structure directives. Tons of different types of sections, but I haven't seen any that would apply. I've looked at .bss, and while I can defines different fields in it, it still reserves space in the program, and I don't need space reserved - I just need a data structure definition so I'm not using magic numbers. Perhaps there is a utility to convert a C struct to an assembly struct that I haven't seen? Surely there has to be a way to define a data structure in assembly.
2
0
519
Jan ’24
Cpp Compiler flags not accessible in the swift for Cpp-Swift Interop
I have a project that has Cpp code and swift code and I m making some calls from swift to cpp. For this I m using the Cpp-swift interop mechanism introduced in swift 5.9 for making direct calls between swift and cpp. I m using module.modulemap file to expose the cpp code to swift. I am facnig an error when I try to access a cpp header that are using the cpp compiler flags in some static assert statements. These methods are working fine in cpp however, when I try to access these methods from swift using the modulemap file, the compiler flags are not being identified by swift, and produces the below error error: use of undeclared identifier 'TW_KERNEL_WINDOWS'. This is my module.modulemap file: module CoreModule { header "ProcessStates.hpp" //cpp header that contains compiler flags export * } below is the cpp header code that I m trying to access in swift: #pragma once // if the given condition is false – treat as an error #define STATIC_CHECKFALSE(condition, message) static_assert (condition, message) STATIC_CHECKFALSE ((TW_KERNEL_WINDOWS == 0) || (TW_KERNEL_WINDOWS == 1), "TW_KERNEL_WINDOWS can only be 0 or 1"); Can someone help, why is this happening and how to resolve this?
5
0
539
Jan ’24
SPM compiler flags passed to main app target
Linker flag specified in Package.swift as unsafe flag is passed to main app target. steps: create empty package and add linkerSettings: [.unsafeFlags(["-Wl,-make_mergeable"])] to target import PackageDescription let package = Package( name: "TestPackage", products: [ // Products define the executables and libraries a package produces, making them visible to other packages. .library( name: "TestPackage", type: .dynamic, targets: ["TestPackage"]), ], targets: [ // Targets are the basic building blocks of a package, defining a module or a test suite. // Targets can depend on other targets in this package and products from dependencies. .target( name: "TestPackage", linkerSettings: [.unsafeFlags(["-Wl,-make_mergeable"])] ), .testTarget( name: "TestPackageTests", dependencies: ["TestPackage"]), ] ) create empty Xcode iOS app project and add package to project via Add Files 3 add package as a framework dependency to the main app in the result, build fails with error: ld: -make_mergeable can only be used when creating a dynamic library package itself builds with -mergable_library and that is fine
2
0
583
Jan ’24
Pass Swift Array To C++ As A std::vector
Hi -- I would like to be able to pass a Swift Array to C++ code. I know it should be possible, but having trouble figuring out the right way to do it. Here is an example class showing what I want to do. C++ code: class Foo { public: Foo(const std::vector<uint8_t> & values) : _values(values) {} protected: std::vector<uint_8> _values; }; Swift code: let values: [UInt8] = [ 1, 2, 3, 4, 5, 6 ] var foo = Foo(values) If I do this, I get the following error message: Cannot convert value of type '[UInt8]' to expected argument type 'std.__1.vector<UInt8, allocator<UInt8>>'.
4
0
882
Jan ’24