Opened 4 years ago

Closed 20 months ago

Last modified 20 months ago

#59515 closed enhancement (fixed)

[icu] : support building with llvm-ar

Reported by: RJVB (René Bertin) Owned by: catap (Kirill A. Korinsky)
Priority: Normal Milestone:
Component: ports Version:
Keywords: haspatch Cc:
Port: icu

Description

I usually configure builds to generate static libraries using llvm-ar instead of (GNU) ar, because this is more or less required when using LTO.

Attached is a modified patch for mh-darwin that drops an argument from ARFLAGS that is not supported by llvm-ar.

Attachments (1)

patch-config-mh-darwin.diff (1.0 KB) - added by RJVB (René Bertin) 20 months ago.
current version for ICU 71; works with all ar variants/versions

Download all attachments as: .zip

Change History (18)

comment:1 Changed 4 years ago by kencu (Ken)

I think you attached the wrong patch?

comment:2 Changed 4 years ago by RJVB (René Bertin)

No, why? This is indeed the modified version of the mh-config patch that I intended to attach.

If you feel like tinkering with this, add the PortGroup below to the portfile and build with +LTO https://github.com/RJVB/macstrop/blob/master/_resources/port1.0/group/LTO-1.0.tcl

comment:3 Changed 4 years ago by kencu (Ken)

oh, you mean just that -c flag?

I was distracted I guess by the bulk of the patch, that does something with the link line selection and rpath.

Interesting Portgroup, will take a look.

comment:4 Changed 3 years ago by kencu (Ken)

Owner: set to kencu
Status: newaccepted

comment:5 Changed 3 years ago by kencu (Ken)

Owner: kencu deleted
Status: acceptedassigned

comment:6 Changed 20 months ago by catap (Kirill A. Korinsky)

Owner: set to catap
Resolution: fixed
Status: assignedclosed

In 3aefb52514bc17fa2d334dd2032ba65514aef03e/macports-ports (master):

icu: update to 71.1

It contains massive revision bump of all ports which depends on icu.

I've also tested to build it with llvm-ar from clang-11 on macOS 10.6
and it works.

Closes: #59515
Closes: #60325
Closes: #64398

[skip ci]

comment:7 in reply to:  6 ; Changed 20 months ago by RJVB (René Bertin)

Replying to catap:

I've also tested to build it with llvm-ar from clang-11 on Mac OS X 10.6 and it works.

That's surprising, because the llvm-ar version (5.0) I tried it with doesn't accept r -c. The -c flag is of little interest anyway a priori, in which case the fix is very simple. I'll check the other llvm-ar versions I have and decide if I propose a patch of a minimum clang version to use.

comment:8 in reply to:  7 Changed 20 months ago by catap (Kirill A. Korinsky)

Replying to RJVB:

That's surprising, because the llvm-ar version (5.0) I tried it with doesn't accept r -c. The -c flag is of little interest anyway a priori, in which case the fix is very simple. I'll check the other llvm-ar versions I have and decide if I propose a patch of a minimum clang version to use.

Have you tried the last llvm? For example 11?

comment:9 Changed 20 months ago by RJVB (René Bertin)

Building clang takes hours on my system, so no (but it's good to know that llvm 9 is apparently not the latest version that'll run on 10.9).

I've found a fix that will work with all versions of *ar. I'll attach it here once I get back to my Mac.

comment:10 in reply to:  9 Changed 20 months ago by catap (Kirill A. Korinsky)

Replying to RJVB:

I've found a fix that will work with all versions of *ar. I'll attach it here once I get back to my Mac.

Maybe you send it to upstream?

Thus, I'll make a -devel port of ICU quite soon ;)

Changed 20 months ago by RJVB (René Bertin)

Attachment: patch-config-mh-darwin.diff added

current version for ICU 71; works with all ar variants/versions

comment:11 Changed 20 months ago by RJVB (René Bertin)

So llvm 5 and earlier do not support r -c, but all ar versions/variants that I tried support the traditional form rc, including the basic ar from the system toolchain. Alternatively the entire change to ARFLAGS could be removed because there is little reason to suppress the single line warning about creating a new archive in MacPorts builds. That might not be the case for regular builds that want to limit output so I'm not certain how appropriate upstreaming this change is. I'll leave that to the port maintainer anyway.

EDIT: yeah, I know, llvm 5 is old, 11 probably so much better yadayada. In practice, builds with v5 are much faster, the binaries (somewhat) smaller and not in any way slower or less correct than builds with much more recent clang versions. In fact, I just see I do have clang-12 installed but deactivated for that reason; I'll report back if my rc fix gives problem with that version.

Last edited 20 months ago by RJVB (René Bertin) (previous) (diff)

comment:12 Changed 20 months ago by catap (Kirill A. Korinsky)

Have you tried to open a PR with your patch?

comment:13 Changed 20 months ago by RJVB (René Bertin)

No, this change is way too simple to warrant that.

comment:14 in reply to:  13 Changed 20 months ago by catap (Kirill A. Korinsky)

Replying to RJVB:

No, this change is way too simple to warrant that.

Well, if you open PR today, it is quite possible that the next release which should happen in weeks will contain it ;)

comment:15 Changed 20 months ago by kencu (Ken)

up until quite recently, llvm-ar could not build universal macho archives, so we were prevented from using it in general MacPorts builds, almost all of which are meant to support universal.

That changed not too long ago when universal macho support was added to llvm-ar.

https://reviews.llvm.org/D85740

I haven't as yet tested which released versions of llvm have that fix in them, but it will be something fairly recent.

Somebody just needs to do a quick test to be sure it works both ways, as a multiple arch thing and as two individual arch things that can be lipo'd together (for example via the muniversal PortGroup).

I think the version of lipo used now enters into the equation too, so have to make sure that is properly tested and vetted too.

Last edited 20 months ago by kencu (Ken) (previous) (diff)

comment:16 Changed 20 months ago by kencu (Ken)

If this is right, it looks like llvm-ar and llvm-lipo support universal in llvm-12 and up:

https://reviews.llvm.org/source/llvm-github/branches/main/;c6f7ac0071a1849a9f8046e2045e1631e224f1bd

comment:17 Changed 20 months ago by RJVB (René Bertin)

Note that this is not about hardwiring the choice for llvm-ar into the port. But I can see how the universal thing makes this contributed patch of mine even less interesting.

Note: See TracTickets for help on using tickets.