* [gentoo-dev] [PATCH] toolchain-funcs: Add tc-ld-is-lld helper.
@ 2019-09-12 11:32 Manoj Gupta
2019-09-13 14:11 ` [gentoo-dev] " Manoj Gupta
0 siblings, 1 reply; 8+ messages in thread
From: Manoj Gupta @ 2019-09-12 11:32 UTC (permalink / raw
To: gentoo-dev; +Cc: Manoj Gupta
LLD is a new linker for LLVM project.
Add tc-ld-is-lld helper to be able to detect it.
Signed-off-by: Manoj Gupta <manojgupta@google.com>
---
eclass/toolchain-funcs.eclass | 30 ++++++++++++++++++++++++++++++
1 file changed, 30 insertions(+)
diff --git a/eclass/toolchain-funcs.eclass b/eclass/toolchain-funcs.eclass
index 7bd90bb4e4a..e358d484417 100644
--- a/eclass/toolchain-funcs.eclass
+++ b/eclass/toolchain-funcs.eclass
@@ -453,6 +453,36 @@ tc-ld-is-gold() {
return 1
}
+# @FUNCTION: tc-ld-is-lld
+# @USAGE: [toolchain prefix]
+# @DESCRIPTION:
+# Return true if the current linker is set to lld.
+tc-ld-is-lld() {
+ local out
+
+ # First check the linker directly.
+ out=$($(tc-getLD "$@") --version 2>&1)
+ if [[ ${out} == *"LLD"* ]] ; then
+ return 0
+ fi
+
+ # Then see if they're selecting lld via compiler flags.
+ # Note: We're assuming they're using LDFLAGS to hold the
+ # options and not CFLAGS/CXXFLAGS.
+ local base="${T}/test-tc-lld"
+ cat <<-EOF > "${base}.c"
+ int main() { return 0; }
+ EOF
+ out=$($(tc-getCC "$@") ${CFLAGS} ${CPPFLAGS} ${LDFLAGS} -Wl,--version "${base}.c" -o "${base}" 2>&1)
+ rm -f "${base}"*
+ if [[ ${out} == *"LLD"* ]] ; then
+ return 0
+ fi
+
+ # No lld here!
+ return 1
+}
+
# @FUNCTION: tc-ld-disable-gold
# @USAGE: [toolchain prefix]
# @DESCRIPTION:
--
2.23.0.162.g0b9fbb3734-goog
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [gentoo-dev] Re: [PATCH] toolchain-funcs: Add tc-ld-is-lld helper.
2019-09-12 11:32 [gentoo-dev] [PATCH] toolchain-funcs: Add tc-ld-is-lld helper Manoj Gupta
@ 2019-09-13 14:11 ` Manoj Gupta
2019-09-13 14:32 ` Ulrich Mueller
2019-09-13 18:44 ` Sergei Trofimovich
0 siblings, 2 replies; 8+ messages in thread
From: Manoj Gupta @ 2019-09-13 14:11 UTC (permalink / raw
To: gentoo-dev
friendly ping for patch review.
On Thu, Sep 12, 2019 at 4:32 AM Manoj Gupta <manojgupta@google.com> wrote:
>
> LLD is a new linker for LLVM project.
> Add tc-ld-is-lld helper to be able to detect it.
>
> Signed-off-by: Manoj Gupta <manojgupta@google.com>
> ---
> eclass/toolchain-funcs.eclass | 30 ++++++++++++++++++++++++++++++
> 1 file changed, 30 insertions(+)
>
> diff --git a/eclass/toolchain-funcs.eclass b/eclass/toolchain-funcs.eclass
> index 7bd90bb4e4a..e358d484417 100644
> --- a/eclass/toolchain-funcs.eclass
> +++ b/eclass/toolchain-funcs.eclass
> @@ -453,6 +453,36 @@ tc-ld-is-gold() {
> return 1
> }
>
> +# @FUNCTION: tc-ld-is-lld
> +# @USAGE: [toolchain prefix]
> +# @DESCRIPTION:
> +# Return true if the current linker is set to lld.
> +tc-ld-is-lld() {
> + local out
> +
> + # First check the linker directly.
> + out=$($(tc-getLD "$@") --version 2>&1)
> + if [[ ${out} == *"LLD"* ]] ; then
> + return 0
> + fi
> +
> + # Then see if they're selecting lld via compiler flags.
> + # Note: We're assuming they're using LDFLAGS to hold the
> + # options and not CFLAGS/CXXFLAGS.
> + local base="${T}/test-tc-lld"
> + cat <<-EOF > "${base}.c"
> + int main() { return 0; }
> + EOF
> + out=$($(tc-getCC "$@") ${CFLAGS} ${CPPFLAGS} ${LDFLAGS} -Wl,--version "${base}.c" -o "${base}" 2>&1)
> + rm -f "${base}"*
> + if [[ ${out} == *"LLD"* ]] ; then
> + return 0
> + fi
> +
> + # No lld here!
> + return 1
> +}
> +
> # @FUNCTION: tc-ld-disable-gold
> # @USAGE: [toolchain prefix]
> # @DESCRIPTION:
> --
> 2.23.0.162.g0b9fbb3734-goog
>
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [gentoo-dev] Re: [PATCH] toolchain-funcs: Add tc-ld-is-lld helper.
2019-09-13 14:11 ` [gentoo-dev] " Manoj Gupta
@ 2019-09-13 14:32 ` Ulrich Mueller
2019-09-13 14:38 ` Manoj Gupta
2019-09-13 18:44 ` Sergei Trofimovich
1 sibling, 1 reply; 8+ messages in thread
From: Ulrich Mueller @ 2019-09-13 14:32 UTC (permalink / raw
To: Manoj Gupta; +Cc: gentoo-dev
[-- Attachment #1: Type: text/plain, Size: 1819 bytes --]
>>>>> On Fri, 13 Sep 2019, Manoj Gupta wrote:
>> LLD is a new linker for LLVM project.
>> Add tc-ld-is-lld helper to be able to detect it.
>>
>> Signed-off-by: Manoj Gupta <manojgupta@google.com>
>> ---
>> eclass/toolchain-funcs.eclass | 30 ++++++++++++++++++++++++++++++
>> 1 file changed, 30 insertions(+)
>>
>> diff --git a/eclass/toolchain-funcs.eclass b/eclass/toolchain-funcs.eclass
>> index 7bd90bb4e4a..e358d484417 100644
>> --- a/eclass/toolchain-funcs.eclass
>> +++ b/eclass/toolchain-funcs.eclass
>> @@ -453,6 +453,36 @@ tc-ld-is-gold() {
>> return 1
>> }
>>
>> +# @FUNCTION: tc-ld-is-lld
>> +# @USAGE: [toolchain prefix]
>> +# @DESCRIPTION:
>> +# Return true if the current linker is set to lld.
>> +tc-ld-is-lld() {
>> + local out
>> +
>> + # First check the linker directly.
>> + out=$($(tc-getLD "$@") --version 2>&1)
Why 2>&1 here, and not 2>/dev/null?
>> + if [[ ${out} == *"LLD"* ]] ; then
>> + return 0
>> + fi
>> +
>> + # Then see if they're selecting lld via compiler flags.
>> + # Note: We're assuming they're using LDFLAGS to hold the
>> + # options and not CFLAGS/CXXFLAGS.
>> + local base="${T}/test-tc-lld"
>> + cat <<-EOF > "${base}.c"
>> + int main() { return 0; }
>> + EOF
>> + out=$($(tc-getCC "$@") ${CFLAGS} ${CPPFLAGS} ${LDFLAGS} -Wl,--version "${base}.c" -o "${base}" 2>&1)
Ditto.
>> + rm -f "${base}"*
>> + if [[ ${out} == *"LLD"* ]] ; then
>> + return 0
>> + fi
>> +
>> + # No lld here!
>> + return 1
The previous 6 lines could be shortened to one:
[[ ${out} == *"LLD"* ]]
>> +}
>> +
>> # @FUNCTION: tc-ld-disable-gold
>> # @USAGE: [toolchain prefix]
>> # @DESCRIPTION:
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 487 bytes --]
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [gentoo-dev] Re: [PATCH] toolchain-funcs: Add tc-ld-is-lld helper.
2019-09-13 14:32 ` Ulrich Mueller
@ 2019-09-13 14:38 ` Manoj Gupta
2019-09-13 14:53 ` Ulrich Mueller
0 siblings, 1 reply; 8+ messages in thread
From: Manoj Gupta @ 2019-09-13 14:38 UTC (permalink / raw
To: Ulrich Mueller; +Cc: gentoo-dev
On Fri, Sep 13, 2019 at 7:32 AM Ulrich Mueller <ulm@gentoo.org> wrote:
>
> >>>>> On Fri, 13 Sep 2019, Manoj Gupta wrote:
>
> >> LLD is a new linker for LLVM project.
> >> Add tc-ld-is-lld helper to be able to detect it.
> >>
> >> Signed-off-by: Manoj Gupta <manojgupta@google.com>
> >> ---
> >> eclass/toolchain-funcs.eclass | 30 ++++++++++++++++++++++++++++++
> >> 1 file changed, 30 insertions(+)
> >>
> >> diff --git a/eclass/toolchain-funcs.eclass b/eclass/toolchain-funcs.eclass
> >> index 7bd90bb4e4a..e358d484417 100644
> >> --- a/eclass/toolchain-funcs.eclass
> >> +++ b/eclass/toolchain-funcs.eclass
> >> @@ -453,6 +453,36 @@ tc-ld-is-gold() {
> >> return 1
> >> }
> >>
> >> +# @FUNCTION: tc-ld-is-lld
> >> +# @USAGE: [toolchain prefix]
> >> +# @DESCRIPTION:
> >> +# Return true if the current linker is set to lld.
> >> +tc-ld-is-lld() {
> >> + local out
> >> +
> >> + # First check the linker directly.
> >> + out=$($(tc-getLD "$@") --version 2>&1)
>
> Why 2>&1 here, and not 2>/dev/null?
>
> >> + if [[ ${out} == *"LLD"* ]] ; then
> >> + return 0
> >> + fi
> >> +
> >> + # Then see if they're selecting lld via compiler flags.
> >> + # Note: We're assuming they're using LDFLAGS to hold the
> >> + # options and not CFLAGS/CXXFLAGS.
> >> + local base="${T}/test-tc-lld"
> >> + cat <<-EOF > "${base}.c"
> >> + int main() { return 0; }
> >> + EOF
> >> + out=$($(tc-getCC "$@") ${CFLAGS} ${CPPFLAGS} ${LDFLAGS} -Wl,--version "${base}.c" -o "${base}" 2>&1)
>
> Ditto.
>
> >> + rm -f "${base}"*
> >> + if [[ ${out} == *"LLD"* ]] ; then
> >> + return 0
> >> + fi
> >> +
> >> + # No lld here!
> >> + return 1
>
> The previous 6 lines could be shortened to one:
> [[ ${out} == *"LLD"* ]]
Thanks for the review. I did it this way to make this an exact copy of
tc-ld-is-gold function above it except the LLD checks.
Should I also change the tc-ld-is-gold function?
>
> >> +}
> >> +
> >> # @FUNCTION: tc-ld-disable-gold
> >> # @USAGE: [toolchain prefix]
> >> # @DESCRIPTION:
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [gentoo-dev] Re: [PATCH] toolchain-funcs: Add tc-ld-is-lld helper.
2019-09-13 14:38 ` Manoj Gupta
@ 2019-09-13 14:53 ` Ulrich Mueller
2019-09-13 18:46 ` Sergei Trofimovich
0 siblings, 1 reply; 8+ messages in thread
From: Ulrich Mueller @ 2019-09-13 14:53 UTC (permalink / raw
To: Manoj Gupta; +Cc: Ulrich Mueller, gentoo-dev
[-- Attachment #1: Type: text/plain, Size: 322 bytes --]
>>>>> On Fri, 13 Sep 2019, Manoj Gupta wrote:
> Thanks for the review. I did it this way to make this an exact copy of
> tc-ld-is-gold function above it except the LLD checks.
> Should I also change the tc-ld-is-gold function?
Good question. Presumably the eclass maintainers should have the last
word on this.
Ulrich
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 487 bytes --]
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [gentoo-dev] Re: [PATCH] toolchain-funcs: Add tc-ld-is-lld helper.
2019-09-13 14:11 ` [gentoo-dev] " Manoj Gupta
2019-09-13 14:32 ` Ulrich Mueller
@ 2019-09-13 18:44 ` Sergei Trofimovich
2019-09-13 18:47 ` Manoj Gupta
1 sibling, 1 reply; 8+ messages in thread
From: Sergei Trofimovich @ 2019-09-13 18:44 UTC (permalink / raw
To: Manoj Gupta; +Cc: gentoo-dev
On Fri, 13 Sep 2019 07:11:03 -0700
Manoj Gupta <manojgupta@google.com> wrote:
> friendly ping for patch review.
Pushed your patch as-is as:
https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=463ec5b25ac36933127e726c553ad83994017aa1
Thank you!
--
Sergei
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [gentoo-dev] Re: [PATCH] toolchain-funcs: Add tc-ld-is-lld helper.
2019-09-13 14:53 ` Ulrich Mueller
@ 2019-09-13 18:46 ` Sergei Trofimovich
0 siblings, 0 replies; 8+ messages in thread
From: Sergei Trofimovich @ 2019-09-13 18:46 UTC (permalink / raw
To: Ulrich Mueller, Manoj Gupta; +Cc: gentoo-dev
On Fri, 13 Sep 2019 16:53:34 +0200
Ulrich Mueller <ulm@gentoo.org> wrote:
> >>>>> On Fri, 13 Sep 2019, Manoj Gupta wrote:
>
> > Thanks for the review. I did it this way to make this an exact copy of
> > tc-ld-is-gold function above it except the LLD checks.
> > Should I also change the tc-ld-is-gold function?
>
> Good question. Presumably the eclass maintainers should have the last
> word on this.
I've pushed the change as-is. You can send follow-up patch. Or I'll get to
to it later.
--
Sergei
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [gentoo-dev] Re: [PATCH] toolchain-funcs: Add tc-ld-is-lld helper.
2019-09-13 18:44 ` Sergei Trofimovich
@ 2019-09-13 18:47 ` Manoj Gupta
0 siblings, 0 replies; 8+ messages in thread
From: Manoj Gupta @ 2019-09-13 18:47 UTC (permalink / raw
To: Sergei Trofimovich; +Cc: gentoo-dev
On Fri, Sep 13, 2019 at 11:45 AM Sergei Trofimovich <slyfox@gentoo.org> wrote:
>
> On Fri, 13 Sep 2019 07:11:03 -0700
> Manoj Gupta <manojgupta@google.com> wrote:
>
> > friendly ping for patch review.
>
> Pushed your patch as-is as:
> https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=463ec5b25ac36933127e726c553ad83994017aa1
Thanks a lot
>
> Thank you!
>
> --
>
> Sergei
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2019-09-13 18:47 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-09-12 11:32 [gentoo-dev] [PATCH] toolchain-funcs: Add tc-ld-is-lld helper Manoj Gupta
2019-09-13 14:11 ` [gentoo-dev] " Manoj Gupta
2019-09-13 14:32 ` Ulrich Mueller
2019-09-13 14:38 ` Manoj Gupta
2019-09-13 14:53 ` Ulrich Mueller
2019-09-13 18:46 ` Sergei Trofimovich
2019-09-13 18:44 ` Sergei Trofimovich
2019-09-13 18:47 ` Manoj Gupta
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox