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

40 Posts
Sort by:
Post not yet marked as solved
5 Replies
613 Views
Dear Experts, I've just received the exciting new email from App Store Connect telling me that I'm using a "required reason" API call and need to declare it in my privacy manifest. Of course this is easy to fix, I'll just add the code to my privacy manifest - but I thought I'd at least go through the motions of trying to work out what function I am calling and from where. First issue is that the email just tells me that the app "references one or more APIs that require reasons ... including NSPrivacyAcceeedAPICategoryFileTimestamp". Dear Apple, why on earth can't you actually tell me the specific function that I am calling? (FB13689896). So let's see if I can work out what has been detected. I look at the app binary: % objdump --syms App.app I think that is probably more or less what App Review must get from their scan, right? So I can see _stat in there but it doesn't know the corresponding source file. So I go to the build directory with the object files and extract symbols from them all individually, using objdump --syms. Provided that I've not enabled link-time optimisation that works and I can find ... zero calls to stat(). Which tells me that my C++ std::filesystem calls have not been detected! Interesting. So if you want to bypass this amazing new privacy technology, I guess that's the way to go. Anyway if there's a call to stat() in the binary but not in the object files, it must be coming from one of my .a files. That's a bit more difficult to track down as (1) my .a files are not in a convenient single directory, and (2) they may have calls to stat() in archive members that aren't needed and aren't included in this binary. So the question: is there some convenient way to take the binary and identify which object files or static library archive members resulted in which of its UND symbols?
Posted
by endecotp.
Last updated
.
Post not yet marked as solved
2 Replies
132 Views
I have a general question that confusing me. I am on M1 and I can build my app on Xcode (or create an archive) for device. Looking in to derived data I can see Debug-iphones (and simulators) folders, I can get the .app and drag/drop it to the simulator. When trying to run the app the app will crash with error: EXEC 14 Binary with wrong platform I understand that it wasn't build for simulators but rather it was build for devices and there fore the crash, but when thinking about it I dont understand why? (at least theoretically it shouldn't crash as it was build for arm64 ). Inspected the binary with lipo it was build for arm64. Comparing the binaries for simulator and device (with otool) I dont see a lot of difference except the rpath. So how does IOS knows it was build for device and not simulator (wrong platform)? is there a way to add some sort of relaxation (in the end both binaries were build for arm64).
Posted Last updated
.
Post not yet marked as solved
4 Replies
221 Views
After upgrading to Xcode 15.3 (15E204a) trivial C++ code of mine no longer compiles: const string text = textComponent->GetText(); auto isEmpty = text.empty() || std::all_of(text.begin(), text.end(), std::isspace); now yields compiler error "No matching function for call to 'all_of'" while working as expected on Version 15.2 (15C500b) and older. Is there a regression in the latest Xcode update C++ support..? Thanks, Jay
Posted
by JayMcBee.
Last updated
.
Post not yet marked as solved
2 Replies
130 Views
I was trying to run some c++ code on clang (I have command line tools installed) but it just showed this error: Undefined symbols for architecture arm64: then it showed bunch of random gibberish here is my code: #include <iostream> #include <vector> using namespace std; typedef std::string type_t; int main(){ type_t name = "Yashar"; cout << "Hello " << name << '\n'; return 0; }
Posted Last updated
.
Post not yet marked as solved
1 Replies
242 Views
I have a library written in C. In the header file it contains #include <inttypes.h>. Library is imported from C++ code as extern "C" { #include <lib.h> } After update to Xcode 15.3 i can't use it because it complains on: Import of C++ module 'std_inttypes_h' appears within extern "C" language linkage specification As I understand inttypes.h is a header from both worlds C and C++ and it could be used in .c code or inside of headers for that code. What would you suggest? I don't want to change library from one side nor disable module validation. It's a valid case and it should compile without an error.
Posted
by molind.
Last updated
.
Post not yet marked as solved
0 Replies
98 Views
My app encountered this error, but I did not use any decompilation project, monkey, etc., and this error occurs occasionally.Has anyone ever encountered a similar error? LLVM Profile Error: Failed to write file "default.profraw": Operation not permitted
Posted
by Kirin233.
Last updated
.
Post not yet marked as solved
3 Replies
351 Views
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.
Posted Last updated
.
Post not yet marked as solved
2 Replies
343 Views
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.
Posted
by toddburch.
Last updated
.
Post not yet marked as solved
3 Replies
351 Views
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.
Posted Last updated
.
Post not yet marked as solved
2 Replies
402 Views
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.
Posted Last updated
.
Post not yet marked as solved
0 Replies
450 Views
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.
Posted
by Mabean.
Last updated
.
Post not yet marked as solved
3 Replies
554 Views
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.
Posted
by zzzzray.
Last updated
.
Post not yet marked as solved
2 Replies
387 Views
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!
Posted
by blake1024.
Last updated
.
Post not yet marked as solved
1 Replies
413 Views
I used the command: utils/build-script --swift-darwin-supported-archs "$(uname -m)" --xcode --clean and encountered the following error: CMake Error at cmake/modules/SwiftUtils.cmake:24 (message): Error! Variable THIN_INPUT_TARGETS is false, empty or not set. Call Stack (most recent call first): stdlib/cmake/modules/AddSwiftStdlib.cmake:3068 (precondition) stdlib/public/libexec/swift-backtrace/CMakeLists.txt:39 (add_swift_target_executable) Please let me know the solution to this error. Thank you. Have a great day as well. 👍
Posted
by devKobe24.
Last updated
.
Post not yet marked as solved
6 Replies
1.6k Views
After upgrading my Xcode from 14.3 to 15.0, there is a compilation error "Unsupported mach-o filetype (only MH_OBJECT and MH_DYLIB can be linked) in libLLVM.dylib". There is no solution found anywhere (Google, Stackoverflow, This forum). The error message is not helpful to locate the root cause. I also tried to read through this page https://iphonedev.wiki/Mach-O_File_Format to know more about LLVM, MH_OBJECT. So far, i cannot find any good reference.
Posted
by Kyochan.
Last updated
.
Post not yet marked as solved
6 Replies
1.7k Views
Our Kotlin MPP code which compiled/linked fine using Xcode 15 Beta 2 no longer links using Xcode 15 Beta 3: ld: unknown options: -ios_simulator_version_min -sdk_version Is the option ios_simulator_version_min removed/renamed? (Intentionally?) Should Apple or JetBrains fix this? (also reported to JetBrains as KT-60238).
Posted
by phirk.
Last updated
.
Post not yet marked as solved
1 Replies
455 Views
Does this exist? Apple seems to have a unique syntax it recognizes (vs GCC arm64 assembler) and getting assembly code cross compiled it for iOS in Xcode has been very frustrating and unfruitful. Is there any guidance on how to do this? The reason for assembly is to support "volk, vector optimized library".
Posted
by W1EBR.
Last updated
.
Post not yet marked as solved
2 Replies
412 Views
Hallo, I am co-author of an open source timetabling software. This software is running many years now on Windows, Linux and MacOS without crashing. So I compiled it with a lot of different compilers and it is always running fine. (with Windows mingw compiler, linux gcc compiler, ...) Now I compiled it on my new Mac and noticed and it is running fine as long as i am compiling it with -o1 or -o2 or -o3 or -ofast or -os or -oz. But as soon as I compile it with -o0, then it crashes with MacOS. It doesn't crash if I compile with -o0 under Linux gcc compiler. I tried to do a minimum example, but as soon as I remove some - in that situation unneeded - code, it is running fine again. So it looks like a memory limit in the compiler or something like that. I don't get it. Any ideas how I can locate and/or fix the bug? You can find the source here: https://lalescu.ro/liviu/fet/forum/index.php?topic=5729.0 I compiled with the latest clang version shipped with latest MacOS Sonoma. I am also attaching the crash report log. Thank you for your help. appleLog.txt.log
Posted
by Volker_D.
Last updated
.
Post not yet marked as solved
0 Replies
491 Views
I just started getting lots of "redefinition of" errors with headers that start with #pragma once. The C++ clang compiler is set to "C++17". Did something change with handling #pragma?
Posted
by W1EBR.
Last updated
.
Post marked as solved
4 Replies
1.3k Views
ld_prime of Xcode 15 produces duplicate symbols when linking a static library containing Objective-C++ object in case using the flags -ObjC and -Wl,force_load. // foo.h #pragma once int Inc(int i); // foo.mm #include "foo.h" #include <Foundation/Foundation.h> @interface Foo : NSObject @end @implementation Foo @end int Inc(int i) { return i + 1; }; // main.cpp #include "foo.h" int main(int argc, const char * argv[]) { return Inc(0); } ❯ clang++ -c foo.mm ❯ ar rcs libfoo.a foo.o ❯ clang++ -framework Foundation libfoo.a -x c++ main.cpp -Wl,-force_load,libfoo.a -ObjC duplicate symbol '__Z3Inci' in: libfoo.a[2](foo.o) libfoo.a[2](foo.o) duplicate symbol '_OBJC_CLASS_$_Foo' in: libfoo.a[2](foo.o) libfoo.a[2](foo.o) duplicate symbol '_OBJC_METACLASS_$_Foo' in: libfoo.a[2](foo.o) libfoo.a[2](foo.o) ld: 3 duplicate symbols clang: error: linker command failed with exit code 1 (use -v to see invocation)```
Posted Last updated
.