how to inhibit -fprofile-instr-generate passed to linker

I'm struggling to build a driver for iPadOS in a particular project configuration. If I put the driver code and dext target into the same Xcode project which contains the iPad app, all is well. This is the way the Xcode driver template does it.

However, I'd like to build and debug the dext on macOS, while eventually deploying on iPadOS. So I put the dext into a different project, which has a macOS target, a minimal iPadOS target and a DriverKit target.

I made a workspace which contains both projects. I dragged the macOS project into the iPadOS project so that I can refer to the products of the macOS project (specifically, its driver target) as a dependency of the iPadOS target.

Note that the main iPad app target depends on the driver target.

So the workspace organization looks like this:

Workspace
  iPad project
      main iPad app target (depends on driver)
      test project reference
  test project
     test macOS/iPad app target
     DriverKit dext target

When I build the iPadOS target, it builds the dependent driver target in the macOS project, but it fails to link because Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/15.0.0/lib/darwin/libclang_rt.profile_driverkit.a is not found.

If I just build the driver target directly in Xcode, there is no such complaint.

I looked closely at the build logs, and I see for the failed link, there are these two linker flags set which are not set in the successful case

-debug_variant
-fprofile-instr-generate

I can't seem to control the generation of this flag. I tried turning off the Profile switch in the Scheme editor for the driver, but is makes no difference. When I directly build the driver target, no -fprofile-instr-generate is set and it compiles and links. When i build the driver as a dependency of another target, -fprofile-instr-generate is passed to the linker, which fails.

The obvious workaround is to put the driver source code into a separate driver target in the iPadOS project, but I'd rather have just one DriverKit driver for both platforms, with a few settings (such as bundle ID) controlled by a configuration file. Has anyone else encountered this problem, and know of a workaround?

Replies

Yes, I am having the same issue. Please let me know how to fix it if some one knows it.