iOS Build Environment Help Center

Build failed on command line

append delete JPark

Windows 10 pro(22H2)
Builder 3.62
iOS SDK 17.2

Compilation is successful, but link is unresponsive

I want to know what the problem is because the error code itself is not displayed

The build.cmd parameter is long. Sorry

log (debugscript) : https://pmbaty.com/paste/?3df5f1c1aa13b380#FhQvmazLxr7hLXfvqWLiq6p3s2uHL15Meed8taY6fdaC

log (non debugscript) : https://pmbaty.com/paste/?cb4ef395aeb1ee72#6XfF4ng6RmpdX8e4dNzHy9oRiUhDUoTDakGP8eTwnXtj

Reply RSS

Replies

append delete #1. Pierre-Marie Baty

Hello

This is a linker crash. As you're using the Apple linker here, does your project build if you use the LLVM one ? To do that, pass the "-lld" option to the build script. Let me know please.

Also, if you need to know how the builder UI exactly invokes the build script, hold the Shift key down while you click the Build button. This will toggle -debugscript, and the first line printed in the log will tell you how exactly it was called.

append delete #2. JPark

If I add -lld to the script and run it
<ld64.lld: error: framework not found for -framework CoreAudioTypes > Error Occurs
Is there a way to see the error in the linker directly?

append delete #3. Pierre-Marie Baty

I'm not sure I understand your last sentence. Unless you're running the linker under supervision of a debugger, I don't see how you can "see the error in the linker directly" ? FWIW this error occurs (in the LLVM source code) in llvm/lld/MachO/Driver.cpp around line 500 :

%
static void addFramework(StringRef name, bool isNeeded, bool isWeak,
                         bool isReexport, bool isExplicit, LoadType loadType) {
  if (Optional<StringRef> path = findFramework(name)) {
    if (loadedObjectFrameworks.contains(*path))
      return;

    InputFile *file =
        addFile(*path, loadType, /*isLazy=*/false, isExplicit, false);
    if (auto *dylibFile = dyn_cast_or_null<DylibFile>(file)) {
      if (isNeeded)
        dylibFile->forceNeeded = true;
      if (isWeak)
        dylibFile->forceWeakImport = true;
      if (isReexport) {
        config->hasReexports = true;
        dylibFile->reexport = true;
      }
    } else if (isa_and_nonnull<ObjFile>(file) ||
               isa_and_nonnull<BitcodeFile>(file)) {
      // Cache frameworks containing object or bitcode files to avoid duplicate
      // symbols. Frameworks containing static archives are cached separately
      // in addFile() to share caching with libraries, and frameworks
      // containing dylibs should allow overwriting of attributes such as
      // forceNeeded by subsequent loads
      loadedObjectFrameworks.insert(*path);
    }
    return;
  }
  error("framework not found for -framework " + name);
}
%

There are several ways a framework specification can be added to the linker's inputs. One of them is through command-line flags (the -framework option). Another one is when implicit (auto-linked) frameworks are encountered in a dylib or framework TDB specification file in the iOS SDK. This occurs when a library or framework is dependent on another one. The Apple linker allows the linking to continue (for in case the framework functions that do depend on the other framework are never called, this won't be a problem and the app is safe), whereas the LLVM linker systematically stops. I just patched it so that it'll continue, in alignment with what Apple's ld64 does and I'm looking for different test cases to validate the change. But you can test it right away : download this updated linker from https://www.pmbaty.com/iosbuildenv/ld64.lld.zip and extract it into the Toolchain directory of the builder's install path. Re-run your script with the -lld flag and let me know what happens.

:: @Pierre-Marie Baty added on 18 Apr ’24 · 22:25

*edit* I found the crash bug in the Apple linker today. If I'm not too unlucky, the next release of the builder will be able to build your project without crashing with the Apple linker (ld64).

append delete #4. JPark

I tried to compile it again with the attached file and it was compiled successfully

Thank you for always responding quickly

append delete #5. Pierre-Marie Baty

Glad to hear. You’re welcome :-)

Reply

(Leave this as-is, it’s a trap!)

There is no need to “register”, just enter the same name + password of your choice every time.

Pro tip: Use markup to add links, quotes and more.

Moderators: Pierre-Marie Baty