All of lore.kernel.org
 help / color / mirror / Atom feed
From: Cyril Hrubis <chrubis@suse.cz>
To: ltp@lists.linux.it
Subject: [LTP] LTP compilation broken with -fno-common
Date: Wed, 1 Apr 2020 11:39:34 +0200	[thread overview]
Message-ID: <20200401093934.GA23773@yuki.lan> (raw)
In-Reply-To: <20200401083228.GA18685@dell5510>

Hi!
> LTP compilation breaks with -fno-common (we don't use as the default).
> This is the default for GCC 10, is there a way to fix it or do we need to disable it?
> 
> Compilation on gcc-10 (or gcc-9 with CFLAGS="-fno-common":
> 
> gcc-9 -Werror=implicit-function-declaration -fno-common -g -O2 -fno-strict-aliasing -pipe -Wall -W -Wold-style-definition -W  -I../../include -I../../include -I../../include/old/   -L../../lib  tst_checkpoint_wait_timeout.c   -lltp -o tst_checkpoint_wait_timeout
> /usr/lib64/gcc/x86_64-suse-linux/9/../../../../x86_64-suse-linux/bin/ld: ../../lib/libltp.a(tst_test.o):ltp.git/lib/../include/tst_test.h:325: multiple definition of `TCID'; /tmp/cc49yYO6.o:ltp.git/lib/tests/tst_strsig.c:27: first defined here
> /usr/lib64/gcc/x86_64-suse-linux/9/../../../../x86_64-suse-linux/bin/ld: ../../lib/libltp.a(tst_sys_conf.o):ltp.git/lib/../include/tst_test.h:325: multiple definition of `TCID'; /tmp/cc49yYO6.o:ltp.git/lib/tests/tst_strsig.c:27: first defined here
> 
> It's somehow related to the "hack" in include/tst_test.h:
> 
> /*
>  * This is a hack to make the testcases link without defining TCID
>  */
> extern const char *TCID;

This is not the original line, the original line is without the extern.

Now this will not be easy to solve since the problem is:

* All old style test define TCID in the test source that also implements main()

* The test library uses that variable in various places

* The variable definition is in the tst_test.h so that all new test also
  define TCID

We cannot move that definition into tst_test.c beacuse that would mean
that old API test would end up with multiple definitions one in the
corresponding test and one in the new library library code.

Maybe we can add it with a weak linker attribute. What about this patch:

diff --git a/include/tst_test.h b/include/tst_test.h
index 259d87d60..352e2cd64 100644
--- a/include/tst_test.h
+++ b/include/tst_test.h
@@ -322,9 +322,7 @@ int main(int argc, char *argv[])
 
 #define TST_TEST_TCONF(message)                                 \
         static struct tst_test test = { .tconf_msg = message  } \
-/*
- * This is a hack to make the testcases link without defining TCID
- */
-const char *TCID;
+
+extern const char *TCID;
 
 #endif /* TST_TEST_H__ */
diff --git a/lib/tst_test.c b/lib/tst_test.c
index 73827d472..4ce8cc301 100644
--- a/lib/tst_test.c
+++ b/lib/tst_test.c
@@ -32,6 +32,11 @@
 #include "old_device.h"
 #include "old_tmpdir.h"
 
+/*
+ * Hack to get TCID defined in newlib tests
+ */
+const char *TCID __attribute__((weak));
+
 #define LINUX_GIT_URL "https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id="
 #define CVE_DB_URL "https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-"



I guess that we can even drop the TCID extern definition from the tst_test.h
header if the weak attribute works fine.


-- 
Cyril Hrubis
chrubis@suse.cz

  parent reply	other threads:[~2020-04-01  9:39 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-04-01  8:32 [LTP] LTP compilation broken with -fno-common Petr Vorel
2020-04-01  9:16 ` Richard Palethorpe
2020-04-01  9:39 ` Cyril Hrubis [this message]
2020-04-01  9:55   ` Martin Doucha
2020-04-01  9:58     ` Cyril Hrubis
2020-04-01 10:04       ` Martin Doucha
2020-04-01 10:15         ` Petr Vorel
2020-04-01 10:50         ` Cyril Hrubis
2020-04-01 11:42           ` Martin Doucha
2020-04-01 12:01             ` Cyril Hrubis
2020-04-01 10:14   ` Petr Vorel
2020-04-09  7:45   ` Petr Vorel
2020-04-09  9:18     ` Cyril Hrubis
2020-04-09 10:06     ` Li Wang
2020-04-15  7:00       ` Petr Vorel
2020-04-15 10:19       ` [LTP] hugemmap01 warnings with -i [was Re: LTP compilation broken with -fno-common] Petr Vorel
2020-04-16  9:13         ` Li Wang

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200401093934.GA23773@yuki.lan \
    --to=chrubis@suse.cz \
    --cc=ltp@lists.linux.it \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.