The LLVM compiler is the next-generation compiler introduced in Xcode 3.2 for Snow Leopard based on the open source LLVM.org project.

Posts under LLVM tag

30 Posts
Sort by:

Post

Replies

Boosts

Views

Activity

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
958
Feb ’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
761
Jan ’24
`setlocale` sets `errno` to `0`
The setlocale C/C++ function writes the global variable errno to 0. In Linux it doesn't have this behavior and the documentation doesn't says anything about setting errno (as I understand, no function should set errno to 0 The following code allows to reproduce it #include <iostream> #include <fstream> using namespace std; int main() { ifstream myStream; myStream.open("NONEXISTENT.txt", ios::in); cout << errno << endl; setlocale(LC_ALL, "en_US.UTF-8"); cout << errno << endl; } // Output: // 2 // 0 I don't think is a compiler issue as the error also happens with gcc but rather a libc issue.
3
0
729
Jan ’24
Xcode 15: MacOSX SDK headers disappear during heavy build
I am facing very strange issue on the last version of Xcode. At some point during heavy build (like building QtWebEngine from the sources) some headers from MacOSX SDK may disappear for the compiler, what leads to the errors. The issue happens build to build. I haven't found any other issue even close to be similar anywhere. The errors during the build looks like this: ../../../../../../../../../../../Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++ -MMD -MF obj/pdf/internal/pdfium_permissions.o.d -DOFFICIAL_BUILD -DTOOLKIT_QT -D_LIBCPP_HAS_NO_ALIGNED_ALLOCATION -DCR_XCODE_VERSION=1510 -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES=0 -DNDEBUG -DNVALGRIND -DDYNAMIC_ANNOTATIONS_ENABLED=0 -DWEBP_EXTERN=extern -DUSE_EGL -DU_USING_ICU_NAMESPACE=0 -DU_ENABLE_DYLOAD=0 -DUSE_CHROMIUM_ICU=1 -DU_ENABLE_TRACING=1 -DU_ENABLE_RESOURCE_TRACING=0 -DU_STATIC_IMPLEMENTATION -DICU_UTIL_DATA_IMPL=ICU_UTIL_DATA_FILE -DUCHAR_TYPE=uint16_t -DV8_COMPRESS_POINTERS -DV8_31BIT_SMIS_ON_64BIT_ARCH -DV8_DEPRECATION_WARNINGS -DV8_REVERSE_JSARGS -DGOOGLE_PROTOBUF_NO_RTTI -DGOOGLE_PROTOBUF_NO_STATIC_INITIALIZER -DHAVE_PTHREAD -DSK_CODEC_DECODES_PNG -DSK_CODEC_DECODES_WEBP -DSK_ENCODE_PNG -DSK_ENCODE_WEBP -DSK_USER_CONFIG_HEADER=\"../../skia/config/SkUserConfig.h\" -DSK_GL -DSK_CODEC_DECODES_JPEG -DSK_ENCODE_JPEG -DSK_USE_LIBGIFCODEC -DSK_SUPPORT_GPU=1 -DSK_GPU_WORKAROUNDS_HEADER=\"gpu/config/gpu_driver_bug_workaround_autogen.h\" -DSK_BUILD_FOR_MAC -DSK_METAL -DPDF_ENABLE_V8 -DPDFIUM_PRINT_TEXT_WITH_GDI -DFT_CONFIG_MODULES_H=\"freetype-custom/freetype/config/ftmodule.h\" -DFT_CONFIG_OPTIONS_H=\"freetype-custom/freetype/config/ftoption.h\" -DPDFIUM_REQUIRED_MODULES -DCHROMIUM_RESTRICT_VISIBILITY -Igen -I../../../../../../../../qte00659ae73d6f/s/qt5/qtwebengine/src/3rdparty/chromium -I../../../../../../../../qte00659ae73d6f/s/qt5/qtwebengine/src/3rdparty/chromium/third_party/pdfium -I../../../../../../../../qte00659ae73d6f/s/qt5/qtwebengine/src/3rdparty/chromium/third_party/perfetto/include -Igen/third_party/perfetto/build_config -Igen/third_party/perfetto -I../../../../../../../../qte00659ae73d6f/s/qt5/qtwebengine/src/3rdparty/chromium/third_party/libwebp/src -I../../../../../../../../qte00659ae73d6f/s/qt5/qtwebengine/src/3rdparty/chromium/third_party/libyuv/include -I../../../../../../../../qte00659ae73d6f/s/qt5/qtwebengine/src/3rdparty/chromium/third_party/jsoncpp/source/include -I../../../../../../../../qte00659ae73d6f/s/qt5/qtwebengine/src/3rdparty/chromium/third_party/khronos -I../../../../../../../../qte00659ae73d6f/s/qt5/qtwebengine/src/3rdparty/chromium/gpu -Igen/third_party/dawn/src/include -I../../../../../../../../qte00659ae73d6f/s/qt5/qtwebengine/src/3rdparty/chromium/third_party/dawn/src/include -I../../../../../../../../qte00659ae73d6f/s/qt5/qtwebengine/src/3rdparty/chromium/third_party/abseil-cpp -I../../../../../../../../qte00659ae73d6f/s/qt5/qtwebengine/src/3rdparty/chromium/third_party/boringssl/src/include -I../../../../../../../../qte00659ae73d6f/s/qt5/qtwebengine/src/3rdparty/chromium/third_party/protobuf/src -Igen/protoc_out -I../../../../../../../../qte00659ae73d6f/s/qt5/qtwebengine/src/3rdparty/chromium/third_party/ced/src -I../../../../../../../../qte00659ae73d6f/s/qt5/qtwebengine/src/3rdparty/chromium/third_party/icu/source/common -I../../../../../../../../qte00659ae73d6f/s/qt5/qtwebengine/src/3rdparty/chromium/third_party/icu/source/i18n -I../../../../../../../../qte00659ae73d6f/s/qt5/qtwebengine/src/3rdparty/chromium/v8/include -Igen/v8/include -I../../../../../../../../qte00659ae73d6f/s/qt5/qtwebengine/src/3rdparty/chromium/third_party/protobuf/src -I../../../../../../../../qte00659ae73d6f/s/qt5/qtwebengine/src/3rdparty/chromium/third_party/skia -I../../../../../../../../qte00659ae73d6f/s/qt5/qtwebengine/src/3rdparty/chromium/third_party/libgifcodec -I../../../../../../../../qte00659ae73d6f/s/qt5/qtwebengine/src/3rdparty/chromium/third_party/freetype/include -I../../../../../../../../qte00659ae73d6f/s/qt5/qtwebengine/src/3rdparty/chromium/third_party/freetype/include/freetype-custom -I../../../../../../../../qte00659ae73d6f/s/qt5/qtwebengine/src/3rdparty/chromium/third_party/freetype/src/include -I../../../../../../../../qte00659ae73d6f/s/qt5/qtwebengine/src/3rdparty/chromium/third_party/harfbuzz-ng/src/src -fno-strict-aliasing -fstack-protector -Wno-unknown-attributes -Wno-unknown-pragmas -Wno-unknown-warning-option -fcolor-diagnostics -fmerge-all-constants -arch x86_64 -Wall -Wextra -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 -Wimplicit-fallthrough -Wunreachable-code -Wthread-safety -Wextra-semi -Wunguarded-availability -Wno-missing-field-initializers -Wno-unused-parameter -Wno-c++11-narrowing -Wno-unneeded-internal-declaration -Wno-undefined-var-template -Wno-psabi -Wno-ignored-pragma-optimize -Wno-implicit-int-float-conversion -Wno-final-dtor-non-final-class -Wno-builtin-assume-aligned-alignment -Wno-deprecated-copy -Wno-non-c-typedef-for-linkage -Wno-max-tokens -O2 -fno-omit-frame-pointer -g0 -isysroot ../../../../../../../../../../../Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.2.sdk -mmacosx-version-min=10.13 -fvisibility=hidden -Wheader-hygiene -Wstring-conversion -Wtautological-overlap-compare -Wshadow -Wno-shorten-64-to-32 -Wno-parentheses-equality -Wno-tautological-compare -Wno-thread-safety-attributes -Wno-undefined-bool-conversion -Wno-tautological-undefined-compare -std=c++14 -fno-trigraphs -Wno-trigraphs -stdlib=libc++ -fno-exceptions -fno-rtti -fvisibility-inlines-hidden -Wno-deprecated-declarations -c ../../../../../../../../qte00659ae73d6f/s/qt5/qtwebengine/src/3rdparty/chromium/pdf/pdfium/pdfium_permissions.cc -o obj/pdf/internal/pdfium_permissions.o In file included from ../../../../../../../../qte00659ae73d6f/s/qt5/qtwebengine/src/3rdparty/chromium/pdf/pdfium/pdfium_permissions.cc:5: In file included from ../../../../../../../../qte00659ae73d6f/s/qt5/qtwebengine/src/3rdparty/chromium/pdf/pdfium/pdfium_permissions.h:8: In file included from ../../../../../../../../qte00659ae73d6f/s/qt5/qtwebengine/src/3rdparty/chromium/pdf/pdf_engine.h:10: ../../../../../../../../../../../Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.2.sdk/usr/include/c++/v1/memory:899:10: fatal error: '__memory/temporary_buffer.h' file not found Failed single commands in proper environment never fails. Errors occur only during really big build. I've opened a bug (https://bugreports.qt.io/browse/QTBUG-119115) in Qt bug tracker. But it seems to be more like a clang bug, because this can happen during any heavy build on 2 different machines (x64 and arm64). There was a suggestion about reaching the limit of opened files. This shouldn't be the case, as clang opens only small amount of them (up to 20 I guess), but I can be wrong.
0
0
850
Dec ’23
Building iOS/Mac Projects With Open Source LLVM
I'd like to use the Clang AST tools for iOS/Mac projects. I want to write C++ programs that link to the Clang libraries. I will use that to analyze the AST from my IOS/Mac projects. I understand you can generate an AST dump from Apple's Clang but I instead want the full capabilities of the Clang libraries, not just the AST output. I believe I need to build compilation databases in order for many Clang libraries to be used. For instance, l'd like to use the CommonOptionsParser which requires arguments for the compilation database. Building these compilation databases is where I'm running to challenges. Its my understanding I will need to use the same LLVM version I'm using for the tooling (open source 17.x) to also build my compilation database. I already tried to use Apple's build-in LLVM to build the database but that led to build arguments such as -index-store-path being included in the JSON, which I don't think Open source LLVM can understand (failing to build). I instead attempted to use the Open Source LLVM installation with my iOS/Mac project. I got it kind of working but am not quite there. My question is whether this approach is worth pursuing? I'm dealing a lot of build errors doing this, particularly in nested swift packages that build fine with Apple Clang. Before I try to fix all these errors, I just wanted to ask whether using Open Source LLVM to build compilation databases for iOS/Mac projects is the right high-level approach for my goals mentioned initially? Is anyone doing this for complicated projects? Another option I thought of is maybe I can "clean up" the compilation database that is generated from Apple's Clang to remove the -index-store-path arguments. Then I could use that as an input to Open Source Clang.
2
0
1.3k
Jan ’24
Beginner Problem: Static Linking
Hi, I just started practicing Static Linking, and I tried to link a third party library into my code, but it kept bugging error: "The header file not found", so I believe there're some steps missing from my code, wish someone can help! Here is the situation: I use OpenGL as the target library, it contains two directories: "Include" directory which holds header files and "lib-arm64"directory which holds "libglfw3.a" and "libglfw.3.dylib". I believe .dylib is related to dynamic linking, so I am not gonna touch that and .a file is the source code I need. Therefore: In Build Phase -&gt; Linking Binary with Library, I attach "libglfw3.a". In Build Setting -&gt; Search Path, I include the address of header directory "Include" in "Header Search Path" and "lib-arm64" in "Library Search Path". "#include &lt;GLFW/glfw3.h&gt;" is the command I copied from OpenGL website template and used in my code. The error is: " 'GLFW/glfw3.h' file not found " If anyone has any advice, feel free to share it, I really appreciate! Another question I have, non-relevant to linking, but to debugging.
3
0
1.1k
Dec ’23
Problem with variadic C functions
I am the author of the open-source Dynace. This is an OO extension to C. It has been in production use for around 20 years. It has been used on DOS, all Windows, Linux, macOS/Intel, VMS, PLAN9, COSMIC, SUNOS, etc. all without a problem. However it does not run on Apple M1, M2 machines. I traced the problem to variadic function calls. I am creating a va_list in a ... function. I then pass the va_list to a second function. I wrote something to copy the the va_list (via va_copy) to see what I am getting. The first function works okay. But the second function does not. (I know you can't re-use a va_list.) I have spend a couple of days on this and can't find a problem with my code. I tried creating a simple example but it worked. Apparently the problem is situational. Anyway, I have no idea what is wrong or what to do next. I'd sure appreciate any help! Thanks!
2
0
780
Nov ’23
[Needs Urgent Help!] Command SwiftCompile failed with a nonzero exit code
Please submit a bug report (https://swift.org/contributing/#reporting-bugs) and include the crash backtrace. Stack dump: 0. Program arguments: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift-frontend -frontend -c /Users/lawrey/Documents/GitHub/IPPTPLUS-IOS/IPPT/Common/Toast/Toast.swift /Users/lawrey/Documents/GitHub/IPPTPLUS-IOS/IPPT/Shop/CheckOutViewController.swift /Users/lawrey/Documents/GitHub/IPPTPLUS-IOS/IPPT/Common/UITextField/NLPaddedTextFieldView.swift ... ... /IPPT.build/Release-iphoneos/IPPT.build/Objects-normal/arm64/SettingsVC.o -index-unit-output-path /IPPT.build/Release-iphoneos/IPPT.build/Objects-normal/arm64/DGElasticPullToRefreshConstants.o -index-unit-output-path /IPPT.build/Release-iphoneos/IPPT.build/Objects-normal/arm64/DGElasticPullToRefreshView.o -index-unit-output-path /IPPT.build/Release-iphoneos/IPPT.build/Objects-normal/arm64/CountDownRouterVC.o -index-unit-output-path /IPPT.build/Release-iphoneos/IPPT.build/Objects-normal/arm64/DatePickerTableViewCell.o -index-unit-output-path /IPPT.build/Release-iphoneos/IPPT.build/Objects-normal/arm64/CircularProgress.o 1. Apple Swift version 5.8 (swiftlang-5.8.0.124.2 clang-1403.0.22.11.100) 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 IPPT) 4. While running pass #670343 SILModuleTransform "DeadFunctionAndGlobalElimination". 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 0x0000000109b7f300 llvm::sys::PrintStackTrace(llvm::raw_ostream&amp;, int) + 56 1 swift-frontend 0x0000000109b7e2e4 llvm::sys::RunSignalHandlers() + 112 2 swift-frontend 0x0000000109b7f910 SignalHandler(int) + 344 3 libsystem_platform.dylib 0x000000019418aa24 _sigtramp + 56 4 swift-frontend 0x00000001052bb65c (anonymous namespace)::DeadFunctionAndGlobalEliminationPass::run() + 424 5 swift-frontend 0x00000001052bb65c (anonymous namespace)::DeadFunctionAndGlobalEliminationPass::run() + 424 6 swift-frontend 0x00000001054214a0 swift::SILPassManager::executePassPipelinePlan(swift::SILPassPipelinePlan const&amp;) + 15312 7 swift-frontend 0x0000000105442a04 swift::SimpleRequest&lt;swift::ExecuteSILPipelineRequest, std::__1::tuple&lt;&gt; (swift::SILPipelineExecutionDescriptor), (swift::RequestFlags)1&gt;::evaluateRequest(swift::ExecuteSILPipelineRequest const&amp;, swift::Evaluator&amp;) + 56 8 swift-frontend 0x0000000105428dd4 llvm::Expected&lt;swift::ExecuteSILPipelineRequest::OutputType&gt; swift::Evaluator::getResultUncached&lt;swift::ExecuteSILPipelineRequest&gt;(swift::ExecuteSILPipelineRequest const&amp;) + 484 9 swift-frontend 0x000000010542b714 swift::runSILOptimizationPasses(swift::SILModule&amp;) + 400 10 swift-frontend 0x0000000104c09c10 swift::CompilerInstance::performSILProcessing(swift::SILModule*) + 524 11 swift-frontend 0x0000000104a6d51c performCompileStepsPostSILGen(swift::CompilerInstance&amp;, std::__1::unique_ptr&lt;swift::SILModule, std::__1::default_delete&lt;swift::SILModule&gt; &gt;, llvm::PointerUnion&lt;swift::ModuleDecl*, swift::SourceFile*&gt;, swift::PrimarySpecificPaths const&amp;, int&amp;, swift::FrontendObserver*) + 1040 12 swift-frontend 0x0000000104a70ab8 performCompile(swift::CompilerInstance&amp;, int&amp;, swift::FrontendObserver*) + 3288 13 swift-frontend 0x0000000104a6e944 swift::performFrontend(llvm::ArrayRef&lt;char const*&gt;, char const*, void*, swift::FrontendObserver*) + 4308 14 swift-frontend 0x0000000104a3368c swift::mainEntry(int, char const**) + 4116 15 dyld 0x0000000193e03f28 start + 2236 Command SwiftCompile failed with a nonzero exit code I need help understanding the root cause to resolve. Overwhelmed by the log :(
4
0
1.7k
Apr ’24
Xcode does not respect '__builtin_available' availability API
I'm writing a simple Command line application on macOS with code using C++, using a API called 'std::to_chars' from charconv void foo(void) {   if (__builtin_available(macOS 10.15, *))   {     char buffer[10];     std::to_chars_result tcr = std::to_chars( buffer, buffer+5, 5 ); #pragma unused (tcr)   }else{     return;   }     } Since Xcode complains main.cpp:19:41: error build: 'to_chars<int, 0>' is unavailable: introduced in macOS 10.15 I wrapped the code with an availability check API in C++, __builtin_available(macOS 10.15, *)) But even with this availability check API, Xcode still failed to compile. Anyone knows why?
1
0
1.6k
Jul ’24
LLVM and Terminal Support on Mac Apple Silicon
My question set is fairly broad, but I can't seem to find any answers anywhere. As a fairly low-level developer, the vast majority of my work is done with Sublime Text, terminal-based compilers, IDEs like Coq's (coq.inria.fr), and code that has to be compiled by terminal. These projects are at the very fabric of what I do, and I fear that Rosetta 2 will be inadequate until LLVM and other systems are updated to run natively on Apple Silicon. Honestly, I can't really afford complex virtualization systems like Parallels or VMWare (not that they help much) and I'd rather not give up MacOS for my Ubuntu desktop. I was raised on MacOS and I can't imagine losing features like scenes or seamless integration with the rest of my electronics. I want to keep my initial post fairly simple and broad, but if anyone has any questions on what I need supported, feel free to ask. I am sure I'm not alone here.
8
1
6.8k
Oct ’24