diff mbox series

[bug#55998] gnu: Add cctools.

Message ID 25870e3b599bef45e57c972d019cbee3228e9e35.1655311589.git.philip@philipmcgrath.com
State Accepted
Headers show
Series [bug#55998] gnu: Add cctools. | expand

Checks

Context Check Description
cbaines/comparison success View comparision
cbaines/git branch success View Git branch
cbaines/applying patch success View Laminar job
cbaines/issue success View issue

Commit Message

Philip McGrath June 15, 2022, 5:15 p.m. UTC
* gnu/packages/darwin.scm: New file.
* gnu/local.mk (GNU_SYSTEM_MODULES): Add it.
* gnu/packages/darwin.scm (cctools): New variable.
---

These tools are used, for example, by Nix [1] and conda-forge [2].

I've used only one small part of this package so far: in [3], I use
`install_name_tool` somewhat like `patchelf` in the process of building the
libgit2 shared library using Guix for distribution as a Racket package. (I
plan to write up for the mailing list what worked well with that approach and
what maybe could work better.)

 -Philip

[1]: https://github.com/NixOS/nixpkgs/blob/master/pkgs/os-specific/darwin/cctools/port.nix
[2]: https://conda-forge.org/blog/posts/2020-10-29-macos-arm64/
[3]: https://github.com/LiberalArtist/native-libgit2-pkgs/tree/build-scripts

 gnu/local.mk            |  1 +
 gnu/packages/darwin.scm | 85 +++++++++++++++++++++++++++++++++++++++++
 2 files changed, 86 insertions(+)
 create mode 100644 gnu/packages/darwin.scm


base-commit: 8a04ac4b2f5d356719d896536dabc95a9520c938

Comments

M June 15, 2022, 6:32 p.m. UTC | #1
Philip McGrath schreef op wo 15-06-2022 om 13:15 [-0400]:
> I've used only one small part of this package so far: in [3],
> 

Nitpick: in libgit2-for-racket.scm:

                ;; it could be provenance.json, but neither
                ;; Racket nor Guix has a pretty-printer

If you use the guile-json library, you can pass ‘#:pretty #true’ to
pretty-print the json.

Greetings,
Maxime.
M June 15, 2022, 6:45 p.m. UTC | #2
Philip McGrath schreef op wo 15-06-2022 om 13:15 [-0400]:
> +      (license license:apsl2))))

Seems to have a problematic cause:

‘13.6 Dispute Resolution. Any litigation or other dispute resolution
between You and Apple relating to this License shall take place in the
Northern District of California, and You and Apple hereby consent to
the personal jurisdiction of, and venue in, the state and federal
courts within that District with respect to this License. The
application of the United Nations Convention on Contracts for the
International Sale of Goods is expressly excluded.’

To me it seems a bit much to require of users _outside_ the US to have
to subject theirselves to the US whenever Apple feels like litigating.

(Is such an unilateral requirement even legal?)

Greetings,
Maxime.
M June 15, 2022, 6:53 p.m. UTC | #3
Philip McGrath schreef op wo 15-06-2022 om 13:15 [-0400]:
> +      (synopsis "Darwin's @code{cctools} and @code{ld64}")
> +      ;; Confusingly enough, the program is called ld64, but the command is
> +      ;; just ld (with no symlink), so @command{ld64} would be wrong.
> +      (description
> +       "Darwin's @code{cctools} are a set of tools somewhat similar in purpose
> +to GNU Binutils, but for Mach-O files targeting Darwin.  The suite includes
> +@command{install_name_tool}, @command{libtool}, and other specialized tools in
> +addition to standard utilities like @command{ld} and @command{as}.  This
> +package provides portable versions of the tools.")
> +      (license license:apsl2))))

How can this work? We don't have any (cross-compiled) Darwin libc
libraries to let it link against. Is this a draft patch?

Greetings,
Maxime.
M June 15, 2022, 6:55 p.m. UTC | #4
Philip McGrath schreef op wo 15-06-2022 om 13:15 [-0400]:
> +                ;; FIXME: This is a very ugly way to make
> +                ;;     #include <linux/limits.h>
> +                ;; work---what is a better way?


Searching for <linux/limit.h> in the guix git checkout, I found:

   ;; Glibc's <limits.h> refers to <linux/limit.h>, for instance, so glibc
   ;; users should automatically pull Linux headers as well.  On GNU/Hurd,
   ;; libc provides <hurd.h>, which includes a bunch of Hurd and Mach headers,
   ;; so both should be propagated.
   (propagated-inputs
    (if (hurd-target?)
        `(("hurd-core-headers" ,hurd-core-headers))
        `(("kernel-headers" ,linux-libre-headers))))

(The hurd bit is not relevant here, and in this case I'd assume that no
propagation is required.)

Greetings,
Maxime.
M June 15, 2022, 6:56 p.m. UTC | #5
Philip McGrath schreef op wo 15-06-2022 om 13:15 [-0400]:
> +      (native-inputs (list clang-toolchain))

Why?  Would the standard GCC compiler suffice?

Greetings,
Maxime.
Philip McGrath June 15, 2022, 7:06 p.m. UTC | #6
On 6/15/22 14:45, Maxime Devos wrote:
> Philip McGrath schreef op wo 15-06-2022 om 13:15 [-0400]:
>> +      (license license:apsl2))))
> 
> Seems to have a problematic cause:
> 
> ‘13.6 Dispute Resolution. Any litigation or other dispute resolution
> between You and Apple relating to this License shall take place in the
> Northern District of California, and You and Apple hereby consent to
> the personal jurisdiction of, and venue in, the state and federal
> courts within that District with respect to this License. The
> application of the United Nations Convention on Contracts for the
> International Sale of Goods is expressly excluded.’
> 
> To me it seems a bit much to require of users _outside_ the US to have
> to subject theirselves to the US whenever Apple feels like litigating.
> 
> (Is such an unilateral requirement even legal?)
> 

I agree that the choice-of-law language is less than friendly to users.

The FSF has issued an opinion [1] that the APSL 2.0 is a free software 
license: they say that "Apple's lawyers worked with the FSF to produce a 
license that would qualify" (after problems with earlier versions of the 
license). They "recommend you do not release new software using this 
license; but it is ok to use and improve software which other people 
release under this license."

IIUC, (guix licenses) only defines FSDG-compatible licenses.

Certainly there are broader community governance questions implicated, 
but I don't think this patch needs to resolve them.

-Philip

[1]: https://www.gnu.org/philosophy/apsl.html
Philip McGrath June 15, 2022, 7:19 p.m. UTC | #7
On 6/15/22 14:53, Maxime Devos wrote:
> Philip McGrath schreef op wo 15-06-2022 om 13:15 [-0400]:
>> +      (synopsis "Darwin's @code{cctools} and @code{ld64}")
>> +      ;; Confusingly enough, the program is called ld64, but the command is
>> +      ;; just ld (with no symlink), so @command{ld64} would be wrong.
>> +      (description
>> +       "Darwin's @code{cctools} are a set of tools somewhat similar in purpose
>> +to GNU Binutils, but for Mach-O files targeting Darwin.  The suite includes
>> +@command{install_name_tool}, @command{libtool}, and other specialized tools in
>> +addition to standard utilities like @command{ld} and @command{as}.  This
>> +package provides portable versions of the tools.")
>> +      (license license:apsl2))))
> 
> How can this work? We don't have any (cross-compiled) Darwin libc
> libraries to let it link against. Is this a draft patch?
> 

Fortunately, we don't need a Darwin libc: tools like `install_name_tool` 
run on GNU/Linux, but work with Darwin binaries, somewhat like 
`patchelf` can work on a cross-compiled binary. From another point of 
view, it's a bit like some parts of MinGW.

This patch is not enough for a Darwin cross-compilation toolchain, 
though I believe it would play a role analogous to GNU Binutils in such 
a toolchain.

Still, several of the tools are useful (albeit niche) on their own, 
which is why I sent this patch now. A whole group of tools supports 
inspecting Mach-O binaries, for example.

-Philip
Philip McGrath June 15, 2022, 7:21 p.m. UTC | #8
On 6/15/22 14:56, Maxime Devos wrote:
> Philip McGrath schreef op wo 15-06-2022 om 13:15 [-0400]:
>> +      (native-inputs (list clang-toolchain))
> 
> Why?  Would the standard GCC compiler suffice?
> 

Unfortunately, these tools are tightly coupled to Clang/LLVM and don't 
support GCC. For example, `otool` is a wrapper around `llvm-objdump`.

-Philip
M June 15, 2022, 7:23 p.m. UTC | #9
Philip McGrath schreef op wo 15-06-2022 om 15:21 [-0400]:
> Unfortunately, these tools are tightly coupled to Clang/LLVM and don't 
> support GCC. For example, `otool` is a wrapper around `llvm-objdump`.

In that case, it needs to be in `inputs`, not `native-inputs`, such
that cross-compiling this cross-compiler can work.

FWIW, you could compile the wrapper `otool` with GCC and at the same
time let `otool` use `llvm-objdump`.

Greetings,
Maxime.
Philip McGrath June 15, 2022, 7:34 p.m. UTC | #10
On 6/15/22 14:55, Maxime Devos wrote:
> Philip McGrath schreef op wo 15-06-2022 om 13:15 [-0400]:
>> +                ;; FIXME: This is a very ugly way to make
>> +                ;;     #include <linux/limits.h>
>> +                ;; work---what is a better way?
> 
> 
> Searching for <linux/limit.h> in the guix git checkout, I found:
> 
>     ;; Glibc's <limits.h> refers to <linux/limit.h>, for instance, so glibc
>     ;; users should automatically pull Linux headers as well.  On GNU/Hurd,
>     ;; libc provides <hurd.h>, which includes a bunch of Hurd and Mach headers,
>     ;; so both should be propagated.
>     (propagated-inputs
>      (if (hurd-target?)
>          `(("hurd-core-headers" ,hurd-core-headers))
>          `(("kernel-headers" ,linux-libre-headers))))
> 
> (The hurd bit is not relevant here, and in this case I'd assume that no
> propagation is required.)
> 

I saw that, too, and I don't understand why <linux/limits.h> (it's 
plural) isn't found automatically, especially when the neighboring 
<limits.h> is found: with both clang-toolchain and gcc-toolchain, 
include/linux is a symlink into linux-libre-headers.

-Philip
M June 15, 2022, 7:35 p.m. UTC | #11
Philip McGrath schreef op wo 15-06-2022 om 15:06 [-0400]:
> I agree that the choice-of-law language is less than friendly to users.
> 
> The FSF has issued an opinion [1] that the APSL 2.0 is a free software 
> license: they say that "Apple's lawyers worked with the FSF to produce a 
> license that would qualify" (after problems with earlier versions of the 
> license)

I am not contesting that FSF considers APSL 2.0 to be a free software
license.  In fact, I looked at that web page to look at why FSF
considers it to be a free software license.  But I didn't find any
answer about the ‘dispute resolution’ clause.  So it seems to me that
FSF overlooked that particular issue, considered it acceptable because
of the US being based in the US, or considered it acceptable due to
some other (unknown) reason.

In case of the FSF overlooking things: mistakes can and should be
corrected (this is a free software distro!).  In case of US-centrism:
err, no.  In case of an unknwon reason: reason is unknown.

The point is being free, not being stamped as free by the FSF.

> IIUC, (guix licenses) only defines FSDG-compatible licenses.

Apparently, it doesn't, given the presence of the APSL 2.0, though
that's a bug.

> Certainly there are broader community governance questions
> implicated, but I don't think this patch needs to resolve them.

I did not ask anything about community governance?

Greetings,
Maxime.
M June 15, 2022, 8:04 p.m. UTC | #12
Philip McGrath schreef op wo 15-06-2022 om 13:15 [-0400]:
> +      (source
> +       (origin
> +         (method git-fetch)
> +         (uri (git-reference
> +               (url "https://github.com/tpoechtrager/cctools-port")
> +               (commit commit)))
> +         (sha256

This contains generated files (look for 'configure' and 'Makefile.in'.
Per standard Guix policy, things need to be built from source.  The
autotools are no exception, see
<https://www.mail-archive.com/guix-devel@gnu.org/msg61160.html>.
They need to be removed, e.g. with delete-file and find-files in a
snippet.

Greetings,
Maxime.
M June 15, 2022, 8:07 p.m. UTC | #13
Philip McGrath schreef op wo 15-06-2022 om 15:19 [-0400]:
> Still, several of the tools are useful (albeit niche) on their own, 
> which is why I sent this patch now. A whole group of tools supports 
> inspecting Mach-O binaries, for example.

Ok, but the package description is implying a linker is available,
which is not the case, due to the lack of a Darwin libc in Guix.

Greetings,
Maxime.
M June 15, 2022, 8:17 p.m. UTC | #14
Philip McGrath schreef op wo 15-06-2022 om 13:15 [-0400]:
> +      (license license:apsl2))))

It's also BSD-4:

https://github.com/tpoechtrager/cctools-port/blob/04663295d0425abfac90a42440a7ec02d7155fea/cctools/gprof/gprof.c#L27

It's also bundling GNUstep code:

https://github.com/tpoechtrager/cctools-port/tree/master/cctools/libobjc2

Greetings,
Maxime.
M June 15, 2022, 8:18 p.m. UTC | #15
Philip McGrath schreef op wo 15-06-2022 om 13:15 [-0400]:
> +      (license license:apsl2))))

There's some Expat licensed code as well:

https://github.com/tpoechtrager/cctools-port/tree/master/cctools/libobjc2

Please investigate the rest as well.

Greetings,
Maxime.
M June 15, 2022, 8:23 p.m. UTC | #16
Philip McGrath schreef op wo 15-06-2022 om 13:15 [-0400]:
> +      (license license:apsl2))))


There's also the GDB General public license:

https://github.com/tpoechtrager/cctools-port/blob/master/cctools/include/gnu/symseg.h

and BSD-3:

https://github.com/tpoechtrager/cctools-port/blob/master/cctools/include/xar/xar.h

and additional term:

 * This file contains Original Code and/or Modifications of Original
Code
 * as defined in and that are subject to the Apple Public Source
License
 * Version 2.0 (the 'License'). You may not use this file except in
 * compliance with the License. The rights granted to you under the
License
 * may not be used to create, or enable the creation or redistribution
of,
 * unlawful or unlicensed copies of an Apple operating system, or to
 * circumvent, violate, or enable the circumvention or violation of,
any
 * terms of an Apple operating system software license agreement.

(in partiular, a reference to an unspecified ‘Apple operating system software
license agreement’)

Greetings,
Maxime.
Philip McGrath June 15, 2022, 9 p.m. UTC | #17
On 6/15/22 15:35, Maxime Devos wrote:
> Philip McGrath schreef op wo 15-06-2022 om 15:06 [-0400]:
>> I agree that the choice-of-law language is less than friendly to users.
>>
>> The FSF has issued an opinion [1] that the APSL 2.0 is a free software
>> license: they say that "Apple's lawyers worked with the FSF to produce a
>> license that would qualify" (after problems with earlier versions of the
>> license)
> 
> I am not contesting that FSF considers APSL 2.0 to be a free software
> license.  In fact, I looked at that web page to look at why FSF
> considers it to be a free software license.  But I didn't find any
> answer about the ‘dispute resolution’ clause.  So it seems to me that
> FSF overlooked that particular issue, considered it acceptable because
> of the US being based in the US, or considered it acceptable due to
> some other (unknown) reason.
> 
> In case of the FSF overlooking things: mistakes can and should be
> corrected (this is a free software distro!).  In case of US-centrism:
> err, no.  In case of an unknwon reason: reason is unknown.
> 

According to 
<https://www.gnu.org/philosophy/free-sw.html#legal-details>, "It is 
acceptable for a free license to specify which jurisdiction's law 
applies, or where litigation must be done, or both."

That paragraph was apparently added in version 1.129, in 2012, but the 
note says that "this was always our policy": 
<https://web.cvs.savannah.gnu.org/viewvc/www/www/philosophy/free-sw.html?r1=1.128&r2=1.129>

So it is not a matter of something being overlooked. Some other FSF-free 
licenses include similar provisions, which generally seem to make the 
license in question not GPL-compatible. For example: 
<https://directory.fsf.org/wiki/License:YPL-1.1>.

> The point is being free, not being stamped as free by the FSF.
> 
>> IIUC, (guix licenses) only defines FSDG-compatible licenses.
> 
> Apparently, it doesn't, given the presence of the APSL 2.0, though
> that's a bug.
> 
>> Certainly there are broader community governance questions
>> implicated, but I don't think this patch needs to resolve them.
> 
> I did not ask anything about community governance?
> 

I meant "community governance" broadly to include questions like, "Who 
decides what 'free' means?" Since I basically agree with statements like 
<https://guix.gnu.org/blog/2019/joint-statement-on-the-gnu-project/>, I 
think there are troubling questions about the FSF's role and how such 
decisions ought to be made in the future. Still, IIUC Guix's current 
policy is 
<https://www.gnu.org/distros/free-system-distribution-guidelines.html>, 
which links to <https://www.gnu.org/philosophy/free-sw.html> for its 
definition of "free license". Bugs are one thing, but this seems to be 
an explicitly allowed under the existing policy, and I don't think this 
patch is the right place to debate substantive changes to Guix's policy.

-Philip
M June 15, 2022, 9:11 p.m. UTC | #18
Philip McGrath schreef op wo 15-06-2022 om 17:00 [-0400]:
> According to 
> <https://www.gnu.org/philosophy/free-sw.html#legal-details>, "It is 
> acceptable for a free license to specify which jurisdiction's law 
> applies, or where litigation must be done, or both."

What

> an explicitly allowed under the existing policy, and I don't think
> this patch is the right place to debate substantive changes to Guix's
> policy.

Maybe move it to guix-devel, and depending on the conclusion, continue
with this patch / drop it?

> I meant "community governance" broadly to include questions like,
> "Who decides what 'free' means?"

Ok, makes sense to me.

Greetings,
Maxime.
\( June 15, 2022, 9:20 p.m. UTC | #19
On Wed Jun 15, 2022 at 10:00 PM BST, Philip McGrath wrote:
> According to 
> <https://www.gnu.org/philosophy/free-sw.html#legal-details>, "It is 
> acceptable for a free license to specify which jurisdiction's law 
> applies, or where litigation must be done, or both."

Although I don't know anything about licensing, wouldn't this mean a
company could, for example, publish software under a license that states
that disputes must be resolved in some theoretical country that bans all
free sharing of software (even if the owner wants to share it), then sue
somebody who's modified the ostensibly free software for copyright
infringement, winning because the country forbids any software sharing,
and still have the license count as free?

I'm probably misunderstanding this; surely there wouldn't be such a
gaping hole in the FSF's free license definition?
Philip McGrath June 16, 2022, 10:29 p.m. UTC | #20
On Wednesday, June 15, 2022 4:17:07 PM EDT Maxime Devos wrote:
> Philip McGrath schreef op wo 15-06-2022 om 13:15 [-0400]:
> > +      (license license:apsl2))))
> 
> It's also BSD-4:
> 
> https://github.com/tpoechtrager/cctools-port/blob/04663295d0425abfac90a42440
> a7ec02d7155fea/cctools/gprof/gprof.c#L27
> 

My understanding is that Guix's practice is to list the overall license or 
licenses of a package, not every permissive license that might apply to 
particular files.

While that file uses the original license header, it's effectively BSD-3-Clause, 
because the University of California retroactively deleted the advertising 
clause in 1999: see <https://www.gnu.org/licenses/bsd.html> and <ftp://
ftp.cs.berkeley.edu/pub/4bsd/README.Impt.License.Change>.

> It's also bundling GNUstep code:
> 
> https://github.com/tpoechtrager/cctools-port/tree/master/cctools/libobjc2
> 

libobjc2 is Expat-licensed—I will look into whether it can be unbundled, but 
it's not a license issue.

-Philip
Philip McGrath June 16, 2022, 11:29 p.m. UTC | #21
On Wednesday, June 15, 2022 4:23:27 PM EDT Maxime Devos wrote:
> Philip McGrath schreef op wo 15-06-2022 om 13:15 [-0400]:
> > +      (license license:apsl2))))
> 
> There's also the GDB General public license:
> 
> https://github.com/tpoechtrager/cctools-port/blob/master/cctools/include/gnu
> /symseg.h
> 

This file is dead code: I will delete it in a snippet and send a patch 
upstream.

> and BSD-3:
> 
> https://github.com/tpoechtrager/cctools-port/blob/master/cctools/include/xar
> /xar.h
> 
> and additional term:
> 
>  * This file contains Original Code and/or Modifications of Original
> Code
>  * as defined in and that are subject to the Apple Public Source
> License
>  * Version 2.0 (the 'License'). You may not use this file except in
>  * compliance with the License. The rights granted to you under the
> License
>  * may not be used to create, or enable the creation or redistribution
> of,
>  * unlawful or unlicensed copies of an Apple operating system, or to
>  * circumvent, violate, or enable the circumvention or violation of,
> any
>  * terms of an Apple operating system software license agreement.
> 
> (in partiular, a reference to an unspecified ‘Apple operating system
> software license agreement’)
> 

I'm not a lawyer, but I read that language as, "The rights granted to you 
under the License may not be used to [do things that are unlawful]." Having  
rights under one license to some program does not make it legal for you to 
violate a completely different license that applies to some other program.

I'd suggest discussing any remaining license issues at <https://lists.gnu.org/
archive/html/guix-devel/2022-06/msg00235.html>, though.

-Philip
M June 17, 2022, 6:14 a.m. UTC | #22
Philip McGrath schreef op do 16-06-2022 om 18:29 [-0400]:
> My understanding is that Guix's practice is to list the overall
> license or licenses of a package, not every permissive license that
> might apply to particular files.

Apparently not fully consistent between packages and packagers?
What I tend to do and recommend, is list all _relevant_ licenses,
without doing an interpretation of what would be the overall license.

FWIW, there was past discussion:

* https://lists.gnu.org/archive/html/guix-devel/2021-05/msg00183.html
* https://lists.gnu.org/archive/html/guix-devel/2021-05/msg00186.html

that was somewhere in between the two endpoints.

Greetings,
Maxime.
Philip McGrath June 17, 2022, 11:09 a.m. UTC | #23
On Wednesday, June 15, 2022 4:04:21 PM EDT Maxime Devos wrote:
> Philip McGrath schreef op wo 15-06-2022 om 13:15 [-0400]:
> > +      (source
> > +       (origin
> > +         (method git-fetch)
> > +         (uri (git-reference
> > +               (url "https://github.com/tpoechtrager/cctools-port")
> > +               (commit commit)))
> > +         (sha256
> 
> This contains generated files (look for 'configure' and 'Makefile.in'.
> Per standard Guix policy, things need to be built from source.  The
> autotools are no exception, see
> <https://www.mail-archive.com/guix-devel@gnu.org/msg61160.html>.
> They need to be removed, e.g. with delete-file and find-files in a
> snippet.
> 

Doing this had the unexpected side-effect of fixing the problem finding <linux/
limits.h>!

A v2 is coming soon.

-Philip
Philip McGrath June 17, 2022, 11:19 a.m. UTC | #24
On Wednesday, June 15, 2022 3:23:48 PM EDT Maxime Devos wrote:
> Philip McGrath schreef op wo 15-06-2022 om 15:21 [-0400]:
> > Unfortunately, these tools are tightly coupled to Clang/LLVM and don't
> > support GCC. For example, `otool` is a wrapper around `llvm-objdump`.
> 
> In that case, it needs to be in `inputs`, not `native-inputs`, such
> that cross-compiling this cross-compiler can work.
> 
> FWIW, you could compile the wrapper `otool` with GCC and at the same
> time let `otool` use `llvm-objdump`.
> 

If that were the only issue, it might be possible, but this package just 
pervasively does not work with GCC. You will not even get past `./configure` 
without Clang.

Nix seemed to only have the LLVM toolchain as a native input, but I've added 
it to `inputs` as well.

-Philip
Philip McGrath June 17, 2022, 11:28 a.m. UTC | #25
On Wednesday, June 15, 2022 4:07:47 PM EDT Maxime Devos wrote:
> Philip McGrath schreef op wo 15-06-2022 om 15:19 [-0400]:
> > Still, several of the tools are useful (albeit niche) on their own,
> > which is why I sent this patch now. A whole group of tools supports
> > inspecting Mach-O binaries, for example.
> 
> Ok, but the package description is implying a linker is available,
> which is not the case, due to the lack of a Darwin libc in Guix.
> 

Concretely, there is an `ld`, and it runs at least enough to print out a usage 
note.

I can't say for certain *why* it works, though the way LLVM doesn't need a 
different binary for each target and the somewhat unusual way linking to libc 
and other system libraries works on Darwin. Though does a linker really need a 
libc? In principle, it could link things that don't link to libc, or even link 
libc itself.

I haven't tried actually linking anything with this package's `ld`, but, even 
if it turns out to not be fully functional yet, this is the package that 
contains Darwin's `ld`.

I did tweak the description in v2 to replace the reference to `libtool`, 
because Darwin's `libtool` is something completely unrelated than the program 
in the Guix package called `libtool`.

-Philip
Ludovic Courtès June 19, 2022, 9:01 p.m. UTC | #26
Hi,

Maxime Devos <maximedevos@telenet.be> skribis:

> Philip McGrath schreef op wo 15-06-2022 om 13:15 [-0400]:
>> +      (source
>> +       (origin
>> +         (method git-fetch)
>> +         (uri (git-reference
>> +               (url "https://github.com/tpoechtrager/cctools-port")
>> +               (commit commit)))
>> +         (sha256
>
> This contains generated files (look for 'configure' and 'Makefile.in'.
> Per standard Guix policy, things need to be built from source.  The
> autotools are no exception, see
> <https://www.mail-archive.com/guix-devel@gnu.org/msg61160.html>.
> They need to be removed, e.g. with delete-file and find-files in a
> snippet.

To be clear, I think this is best described as “Guix policy-to-be”—we
have yet to write this down and actually implement it consistently.

Ludo’.
diff mbox series

Patch

diff --git a/gnu/local.mk b/gnu/local.mk
index 5a9edc16bb..3987a499d9 100644
--- a/gnu/local.mk
+++ b/gnu/local.mk
@@ -181,6 +181,7 @@  GNU_SYSTEM_MODULES =				\
   %D%/packages/cvassistant.scm			\
   %D%/packages/cybersecurity.scm		\
   %D%/packages/cyrus-sasl.scm			\
+  %D%/packages/darwin.scm			\
   %D%/packages/databases.scm			\
   %D%/packages/datamash.scm			\
   %D%/packages/datastructures.scm		\
diff --git a/gnu/packages/darwin.scm b/gnu/packages/darwin.scm
new file mode 100644
index 0000000000..48bba70dc5
--- /dev/null
+++ b/gnu/packages/darwin.scm
@@ -0,0 +1,85 @@ 
+;;; GNU Guix --- Functional package management for GNU
+;;; Copyright © 2022 Philip McGrath <philip@philipmcgrath.com>
+;;;
+;;; This file is part of GNU Guix.
+;;;
+;;; GNU Guix is free software; you can redistribute it and/or modify it
+;;; under the terms of the GNU General Public License as published by
+;;; the Free Software Foundation; either version 3 of the License, or (at
+;;; your option) any later version.
+;;;
+;;; GNU Guix is distributed in the hope that it will be useful, but
+;;; WITHOUT ANY WARRANTY; without even the implied warranty of
+;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+;;; GNU General Public License for more details.
+;;;
+;;; You should have received a copy of the GNU General Public License
+;;; along with GNU Guix.  If not, see <http://www.gnu.org/licenses/>.
+
+(define-module (gnu packages darwin)
+  #:use-module (gnu packages)
+  #:use-module (gnu packages llvm)
+  #:use-module (guix build-system gnu)
+  #:use-module (guix gexp)
+  #:use-module (guix git-download)
+  #:use-module (guix packages)
+  #:use-module (guix utils)
+  #:use-module ((guix licenses) #:prefix license:))
+
+(define-public cctools
+  (let ((cctools-version "973.0.1")
+        (ld64-version "609")
+        (revision "0")
+        (commit "04663295d0425abfac90a42440a7ec02d7155fea"))
+    (package
+      (name "cctools")
+      (version (git-version (string-append cctools-version
+                                           "-ld64-"
+                                           ld64-version)
+                            revision
+                            commit))
+      (source
+       (origin
+         (method git-fetch)
+         (uri (git-reference
+               (url "https://github.com/tpoechtrager/cctools-port")
+               (commit commit)))
+         (sha256
+          (base32 "0vihfa8y64vvd3pxy8qh4mhcnzinxh9flpz9dvw4wch4zj2nnfjs"))
+         (file-name (git-file-name name version))))
+      (build-system gnu-build-system)
+      (native-inputs (list clang-toolchain))
+      (arguments
+       (list
+        #:phases
+        #~(modify-phases %standard-phases
+            (add-after 'unpack 'chdir
+              (lambda args
+                (chdir "cctools")))
+            (add-after 'chdir 'find-linux-limits-h
+              (lambda* (#:key inputs #:allow-other-keys)
+                ;; FIXME: This is a very ugly way to make
+                ;;     #include <linux/limits.h>
+                ;; work---what is a better way?
+                (setenv "CPATH"
+                        (list->search-path-as-string
+                         (cons #$(file-append
+                                  (this-package-native-input "clang-toolchain")
+                                  "/include")
+                               (cond
+                                ((getenv "CPATH")
+                                 => search-path-as-string->list)
+                                (else
+                                 '())))
+                         ":")))))))
+      (home-page "https://github.com/tpoechtrager/cctools-port")
+      (synopsis "Darwin's @code{cctools} and @code{ld64}")
+      ;; Confusingly enough, the program is called ld64, but the command is
+      ;; just ld (with no symlink), so @command{ld64} would be wrong.
+      (description
+       "Darwin's @code{cctools} are a set of tools somewhat similar in purpose
+to GNU Binutils, but for Mach-O files targeting Darwin.  The suite includes
+@command{install_name_tool}, @command{libtool}, and other specialized tools in
+addition to standard utilities like @command{ld} and @command{as}.  This
+package provides portable versions of the tools.")
+      (license license:apsl2))))