blob: a5ded602e527d664f02ecba7060b224ffddb1b0d [file] [log] [blame]
Brad Bishop19323692019-04-05 15:28:33 -04001From 694eba7bb974f6b8bd308804cb24350150108b2b Mon Sep 17 00:00:00 2001
2From: He Zhe <zhe.he@windriver.com>
3Date: Wed, 21 Nov 2018 15:12:43 +0800
4Subject: [PATCH] scripts: Use fixed input and output files instead of pipe for here-doc
5
6There was a bug of "as" in binutils that when it checks if the input file and
7output file are the same one, it would not check if they are on the same block
8device. The check is introduced by the following commit in v2.31.
9
10https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;a=commit;h=
1167f846b59b32f3d704c601669409c2584383fea9
12
13The here-doc usage in this script creates temporary file in /tmp. When we run in
14an environment where /tmp has rarely been used, the newly created temporary file
15may have a very low inode number. If the inode number was 6 which is the same as
16/dev/null, the as would wrongly think the input file and the output file are the
17same and report the following error.
18
19*** Compiler lacks asm-goto support.. Stop.
20
21One observed case happened in docker where the /tmp could be so rarely used that
22very low number inode may be allocated and triggers the error.
23
24The fix below for the bug only exists on the master branch of binutils so far
25and has not been released from upstream. As the convict is introduced since
26v2.31, only v2.31 is affected.
27
28https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;a=commit;h=
292a50366ded329bfb39d387253450c9d5302c3503
30
31When building linux-libc-headers we need to use "as" in binutils which does not
32contain the fix for the moment. To work around the error, we create a fixed
33temporary file to contain the program being tested.
34
35This patch also removes ">/dev/null 2>&1" so we will have more direct error
36information in case something else wrong happened.
37
38Upstream-Status: Inappropriate [A work around for binutils v2.31]
39
40Signed-off-by: He Zhe <zhe.he@windriver.com>
41---
42 scripts/gcc-goto.sh | 5 ++++-
43 1 file changed, 4 insertions(+), 1 deletion(-)
44
45diff --git a/scripts/gcc-goto.sh b/scripts/gcc-goto.sh
46index 8b980fb22..d256a9438 100755
47--- a/scripts/gcc-goto.sh
48+++ b/scripts/gcc-goto.sh
49@@ -3,7 +3,7 @@
50 # Test for gcc 'asm goto' support
51 # Copyright (C) 2010, Jason Baron <jbaron@redhat.com>
52
53-cat << "END" | $@ -x c - -fno-PIE -c -o /dev/null
54+cat << "END" > ./input
55 int main(void)
56 {
57 #if defined(__arm__) || defined(__aarch64__)
58@@ -20,3 +20,6 @@ entry:
59 return 0;
60 }
61 END
62+
63+$@ -x c ./input -fno-PIE -c -o ./output
64+rm ./input ./output
65--
662.19.1
67