public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
From: "HON  LUU" <hon@dreambigsemi.com>
To: Segher Boessenkool <segher@kernel.crashing.org>
Cc: "gcc-help@gcc.gnu.org" <gcc-help@gcc.gnu.org>
Subject: RE: gcc question
Date: Mon, 13 Sep 2021 19:10:46 +0000	[thread overview]
Message-ID: <VI1PR02MB31187EE0CB296CF07056A914DDD99@VI1PR02MB3118.eurprd02.prod.outlook.com> (raw)
In-Reply-To: <DB6PR02MB3111AB3D949B72434D4E414EDDD79@DB6PR02MB3111.eurprd02.prod.outlook.com>

Hi Segher,

Sorry to bother you, but I don't know how to proceed.
Anything that you can give me is greatly appreciated.
Anything you want me to do please let me know.

Thank you very much for your time,
Hon

-----Original Message-----
From: HON LUU 
Sent: Saturday, September 11, 2021 2:08 PM
To: Segher Boessenkool <segher@kernel.crashing.org>
Cc: gcc-help@gcc.gnu.org
Subject: RE: gcc question

Hi Segher,

Following is more information that I can collect. Please let me know if you need anything else.
Thank you very much for your help.

Regards,
Hon
=====================================================================

+ this is part of the content of cdev.c, from which the error happened
...
...
struct static_key_false test;

int qdma_cdev_init(void) {
   
    if (static_branch_unlikely(&test)) {
        printk("test...\n");
    }
	return 0;
}

void qdma_cdev_cleanup(void) {
}
...

+ static_branch_unlikely is defined as followed from /lib/modules/`uname -r`/build/include/linux/jump_label.h :

#define static_branch_unlikely(x)						\
({										\
	bool branch;								\
	if (__builtin_types_compatible_p(typeof(*x), struct static_key_true))	\
		branch = arch_static_branch_jump(&(x)->key, false);		\
	else if (__builtin_types_compatible_p(typeof(*x), struct static_key_false)) \
		branch = arch_static_branch(&(x)->key, false);			\
	else									\
		branch = ____wrong_branch_error();				\
	unlikely(branch);							\
})

+ the error is related to arch_static_branch_jump() which is defined from /lib/modules/`uname -r`/build/arch/x86/include/asm/jump_label.h as followed:

static __always_inline bool arch_static_branch(struct static_key *key, bool branch) {
	asm_volatile_goto("1:"
		".byte " __stringify(STATIC_KEY_INIT_NOP) "\n\t"
		".pushsection __jump_table,  \"aw\" \n\t"
		_ASM_ALIGN "\n\t"
		_ASM_PTR "1b, %l[l_yes], %c0 + %c1 \n\t"
		".popsection \n\t"
		: :  "i" (key),  "i" (branch) : : l_yes);

	return false;
l_yes:
	return true;
}

+ The code compiled successfully in kernel mode with followed command:
    + make V=1 clean
    + make V=1
+ The code failed to compile when I try to compile into user space mode with the followed command:
    + make -f Makefile.user clean
    + make -f Makefile.user
+ Note that the difference between gcc command line between the 2 modes are:
    + kernel:      .... -fno-PIE ... -mcmodel=kernel ...
    + user space:  .... -fPIC    ... <  removed    > ...
+ Another interesting note is:
    + if I remove -fPIC from user space gcc command, then the code compile successfully. However -fPIC is the must for my project.


-----Original Message-----
From: Segher Boessenkool <segher@kernel.crashing.org>
Sent: Friday, September 10, 2021 11:36 AM
To: HON LUU <hon@dreambigsemi.com>
Cc: gcc-help@gcc.gnu.org
Subject: Re: gcc question

On Fri, Sep 10, 2021 at 05:58:07PM +0000, HON  LUU wrote:
> Hi Segher,
> 
> I wonder if you have any issues to reproduce the problem.

> Attached is the tar ball of stand alone module, which duplicate the issue.
> There is a README file, should be straightforward to duplicate the issue.

> You need to show the full code of the asm_volatile_goto, and the declarations of everything used in its operands, for us to get a handle on what is going on here.  Bonus points if you manage to make a stand- alone compilable testcase that shows the problem.

If you write up a good email with all the necessary info, you will get an answer (and a good answer!) much quicker.  I do not particularly feel like doing all the work here.  Sorry.


Segher

  reply	other threads:[~2021-09-13 19:10 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-09-08 15:06 HON  LUU
2021-09-08 16:20 ` Segher Boessenkool
2021-09-08 16:26   ` HON  LUU
2021-09-08 16:27   ` HON  LUU
2021-09-08 17:05   ` HON  LUU
2021-09-08 23:13     ` HON  LUU
2021-09-10 17:58       ` HON  LUU
2021-09-10 18:36         ` Segher Boessenkool
2021-09-11 21:08           ` HON  LUU
2021-09-13 19:10             ` HON  LUU [this message]
2021-09-13 19:22             ` Florian Weimer
2021-09-13 19:40               ` HON  LUU
2021-09-13 19:42                 ` HON  LUU
2021-09-13 19:42                 ` Florian Weimer
2021-09-13 19:50                   ` HON  LUU
2021-09-13 19:51                     ` Florian Weimer
2021-09-13 19:52                       ` HON  LUU
  -- strict thread matches above, loose matches on Subject: below --
2006-02-26 22:53 Brendan Darrer
2006-02-26 23:52 ` Ernest L. Williams Jr.
2006-02-27 15:29 ` Brian Budge
2002-06-12  9:29 j y
2002-06-12 11:16 ` Shawn Starr
2001-07-20  4:35 Steve Kieu
2000-08-13 19:34 tao tong
2000-04-10  7:46 GCC question Gibson, Terry
2000-04-10  8:12 ` Alexandre Oliva
2000-01-06 15:46 Black, Christopher T
2000-04-01  0:00 ` Black, Christopher T
     [not found] <947048956.20674.ezmlm@gcc.gnu.org>
2000-01-04 21:22 ` John Ratcliff
2000-04-01  0:00   ` John Ratcliff

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=VI1PR02MB31187EE0CB296CF07056A914DDD99@VI1PR02MB3118.eurprd02.prod.outlook.com \
    --to=hon@dreambigsemi.com \
    --cc=gcc-help@gcc.gnu.org \
    --cc=segher@kernel.crashing.org \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).