Opened 6 months ago

Last modified 10 days ago

#57137 new enhancement

xcode portgroup should set -derivedDataPath on Xcode versions that need it

Reported by: ryandesign (Ryan Schmidt) Owned by:
Priority: Normal Milestone:
Component: ports Version:
Keywords: Cc: l2dy (Zero King), yan12125 (Chih-Hsuan Yen), ddrum2000, mndavidoff (Monte Davidoff), Schamschula (Marius Schamschula), eborisch (Eric A. Borisch), raimue (Rainer Müller), mtn88 (Max), inyeollee, wahspilihp (Philip Shaw), markemer (Mark Anderson), szhorvat (Szabolcs Horvát), AlD (Daniel Albers), jeremyhu (Jeremy Huddleston Sequoia), ShadSterling (Shad Sterling)
Port: xcode-1.0.tcl

Description

Ports that use the xcode 1.0 portgroup fail to build at least on Xcode 9.4 and 10.0 GM, because they cannot write to the derived data path. By default Xcode uses a derived data path inside the home directory, but fails to honor the HOME environment variable MacPorts specifies, so it tries to write into the macports user's home directory which is not writable.

To work around this, the poedit port manually specifies the derived data path, and I copied this usage to the MoltenVK port when I created it, but every other port that builds with xcodebuild (such a graphviz-gui or Readown) has failed to build for me in the same way, so I think we need to move that fix into the portgroup.

It looks like the -derivedDataPath flag is available in xcodebuild 5 and later (Mountain Lion and later). So we could add the flag for Xcode 5 and later, assuming it does no harm, though surely these ports haven't been broken since Mountain Lion. I suspect some new version of Xcode must have introduced a change. Do we know what version that might be?

Attachments (1)

main.log (352.8 KB) - added by ddrum2000 6 months ago.
From building graphviz-gui

Download all attachments as: .zip

Change History (23)

comment:1 Changed 6 months ago by yan12125 (Chih-Hsuan Yen)

Cc: yan12125 added

comment:2 Changed 6 months ago by kencu (Ken)

I noticed three things that appear to be general xcode PG issues while fixing aquaterm and looking over irrlicht...

  1. why do we run a build phase, when the build always seems to occur again in the destroot phase anyway, and sometimes this causes errors?
  2. the -derivedDataPath issue
  3. at least on Xcode 10, the -derivedDataPath flag was only accepted on aquaterm if there was also a scheme, which so far seems to be the same as ${xcode.target}

SO -- I am wondering if the xcode PG might just add the following as a default, as it seems to be working for me so far on several ports:

build                   {}
destroot.pre_args       -derivedDataPath ./DerivedData
xcode.scheme            ${xcode.target}
Last edited 6 months ago by kencu (Ken) (previous) (diff)

comment:3 in reply to:  2 Changed 6 months ago by ryandesign (Ryan Schmidt)

Replying to kencu:

I noticed three things that appear to be general xcode PG issues while fixing aquaterm and looking over irrlicht...

  1. why do we run a build phase, when the build always seems to occur again in the destroot phase anyway, and sometimes this causes errors?

I have noticed that some Xcode-using ports do that. I do not know why that happens. Some Xcode-using ports override the destroot phase entirely, perhaps in order to combat that. In MacPorts we should be building in the build phase and destrooting in the destroot phase. If we are not doing that for Xcode-using ports, we should figure out a way to fix that.

  1. the -derivedDataPath issue
  2. at least on Xcode 10, the -derivedDataPath flag is only accepted if there is a scheme, which so far seems to be the same as ${xcode.target}

SO -- I am wondering if the xcode PG might just add the following as a default, as it seems to be working for me so far on several ports:

build                   {}
destroot.pre_args       -derivedDataPath ./DerivedData
xcode.scheme            ${xcode.target}

I wasn't aware that Xcode required a scheme to use the derived data path.

A scheme is not the same thing as a target, that's why there are separate settings in the portgroup.

comment:4 Changed 6 months ago by kencu (Ken)

I assume the xcode PG's "destroot" phase runs some "build-then-install" logic in Xcode that might be hard to dissect...

It could be you either choose destrooting in the build phase or building in the destroot phase :>

comment:5 Changed 6 months ago by ryandesign (Ryan Schmidt)

It would be silly if we had to use either of those in general for all Xcode-using ports.

Perhaps there is something that some Xcode projects do that causes this to happen.

Maybe this used to work the way we wanted in older versions of Xcode, back when the portgroup was added, and something broke or changed in newer versions of Xcode.

Changed 6 months ago by ddrum2000

Attachment: main.log added

From building graphviz-gui

comment:6 Changed 6 months ago by ddrum2000

Sorry for the double post I accidentally started above.

I suspect I have the same problem when trying to build graphviz-gui. I'm running Mojave with Xcode 10. I have attached a log file in the previous post.

Last edited 6 months ago by ddrum2000 (previous) (diff)

comment:7 in reply to:  6 Changed 6 months ago by ryandesign (Ryan Schmidt)

Cc: ddrum2000 added

Replying to ddrum2000:

So I suspect I have the same problem when trying to build graphviz-gui. I'm running Mojave with Xcode 10. I have attached a log file.

Right, that's the problem you'll see building most any port that uses xcodebuild, with new versions of Xcode.

We need to decide under what conditions to add the -derivedDataPath flag to the xcode portgroup. Should we add it for Xcode 5 and later, since the option appeared in that version? Or should we only add it on the versions of Xcode where it fails if we don't, and if so, what versions are those?

We also need clarity on the scheme issue Ken raised.

comment:8 Changed 6 months ago by mndavidoff (Monte Davidoff)

Cc: mndavidoff added

comment:9 in reply to:  4 Changed 6 months ago by jmroot (Joshua Root)

Replying to kencu:

I assume the xcode PG's "destroot" phase runs some "build-then-install" logic in Xcode that might be hard to dissect...

Note that there is a confirmed bug with the new build system in Xcode 10 that causes problems with building and then destrooting separately, but not when doing both in one step. See [9cb3c083519503bb4b404fe57f19466a924523be/macports-ports] and IRC logs of 26th-27th September (starting around 22:40).

comment:10 Changed 6 months ago by Schamschula (Marius Schamschula)

Cc: Schamschula added

comment:11 Changed 6 months ago by eborisch (Eric A. Borisch)

Cc: eborisch added

comment:12 Changed 6 months ago by raimue (Rainer Müller)

Cc: raimue added

comment:13 Changed 5 months ago by ryandesign (Ryan Schmidt)

Cc: mtn88 added

Has duplicate #57223.

comment:14 Changed 5 months ago by inyeollee

Cc: inyeollee added

comment:15 Changed 5 months ago by wahspilihp (Philip Shaw)

Cc: wahspilihp added

comment:16 Changed 5 months ago by markemer (Mark Anderson)

Cc: markemer added

comment:17 Changed 5 months ago by szhorvat (Szabolcs Horvát)

Cc: szhorvat added

comment:18 Changed 5 months ago by AlD (Daniel Albers)

Cc: AlD added

comment:19 Changed 4 months ago by jeremyhu (Jeremy Huddleston Sequoia)

Has someone filed a radar about this issue? Please provide a reference to it.

comment:20 Changed 4 months ago by jeremyhu (Jeremy Huddleston Sequoia)

Cc: jeremyhu added

comment:21 in reply to:  19 Changed 3 months ago by jmroot (Joshua Root)

Replying to jeremyhu:

Has someone filed a radar about this issue? Please provide a reference to it.

Toby filed one about the problem I mentioned in comment:9. He didn't mention the number unfortunately; you'd have to ask him. I'm not clear on whether there are multiple separate issues here or if they're all related.

comment:22 Changed 10 days ago by ShadSterling (Shad Sterling)

Cc: ShadSterling added
Note: See TracTickets for help on using tickets.