Gentoo Archives: gentoo-dev

From: Mike Gilbert <floppym@g.o>
To: Gentoo Dev <gentoo-dev@l.g.o>
Subject: Re: [gentoo-dev] [PATCH] meson.eclass: implement basic cross-compiler support
Date: Mon, 29 May 2017 21:40:30
Message-Id: CAJ0EP40DR1OtBDY8=16=MmNphx5s2PMANfrk99dnhtSqFt_Q5w@mail.gmail.com
In Reply to: Re: [gentoo-dev] [PATCH] meson.eclass: implement basic cross-compiler support by "Michał Górny"
1 On Mon, May 29, 2017 at 5:06 PM, Michał Górny <mgorny@g.o> wrote:
2 > On pon, 2017-05-29 at 16:58 -0400, Mike Gilbert wrote:
3 >> + # system roughly corresponds to uname -s (lowercase)
4 >> + local system=unknown
5 >> + case ${CHOST} in
6 >> + *-aix*) system=aix ;;
7 >> + *-cygwin*) system=cygwin ;;
8 >> + *-darwin*) system=darwin ;;
9 >> + *-freebsd*) system=freebsd ;;
10 >> + *-linux*) system=linux ;;
11 >> + *-solaris*) system=sunos ;;
12 >
13 > Don't you want to die on unknown system? Or is it likely to work anyway?
14
15 Good question.
16
17 The 'system' property controls some built-in logic in meson itself
18 (mainly for MS Windows), and may be referenced by project files as
19 'host_machine.system()'. Setting it to 'unknown' may cause failures
20 for projects that actually look at it.
21
22 However, I think most projects would work without having this set to a
23 known value.
24
25 >> + esac
26 >> +
27 >> + local cpu_family=$(tc-arch)
28 >> + case ${cpu_family} in
29 >> + amd64) cpu_family=x86_64 ;;
30 >> + arm64) cpu_family=aarch64 ;;
31 >
32 > That's purely mapping from known-wrong values, correct? Maybe it'd be
33 > reasonable to assert for all correct too, and fail on unknown?
34
35 Yes, it corrects two obvious deviations from uname -m on Linux. x86 is
36 ok since that is what meson expects/generates for i?86.
37
38 I'm not sure what you mean by "assert for all correct"; if you mean
39 check for all valid values for cpu_family, such a list does not exist.
40
41 Similar to 'system' this property may or may not be used depending on
42 the project. Defaulting to "unknown" should be fine in many cases. I
43 don't think we need to fail.
44
45 >> + # Both meson(1) and _meson_create_cross_file need these
46 >> + tc-export AR CC CXX STRIP
47 >
48 > Wouldn't it be reasonable to make them local first anyway? I would try
49 > to avoid polluting the environment.
50
51 Makes sense. I'll revise this to "local -x CC=$(tc-getCC)", etc.