public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/100005] New: undefined reference to `_rdrand64_step'
@ 2021-04-09 17:10 thiago at kde dot org
  2021-04-09 17:15 ` [Bug c/100005] " redi at gcc dot gnu.org
                   ` (17 more replies)
  0 siblings, 18 replies; 19+ messages in thread
From: thiago at kde dot org @ 2021-04-09 17:10 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100005

            Bug ID: 100005
           Summary: undefined reference to `_rdrand64_step'
           Product: gcc
           Version: 11.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: thiago at kde dot org
  Target Milestone: ---

$ cat rdrand.c
#include <immintrin.h>

#define NUM_RANDOM_NUMBERS_TO_GENERATE  1024

typedef int (*Generator)(unsigned long long *);

int fill_array(Generator generator, unsigned long long *rand_array)
{
    for (int i = 0; i < NUM_RANDOM_NUMBERS_TO_GENERATE; i++) {
        // fast attempt once:
        if (__builtin_expect(generator(&rand_array[i]), 1))
            continue;

        // retry up to 16 times
        int j;
        for (j = 0; j < 16; ++j) {
            if (generator(&rand_array[i]))
                break;
        }
        if (j == 16) {
            // failed, the RNG is out of entropy
            return -1;
        }
    }

    return 0;
}

int main()
{
    unsigned long long rand_array[NUM_RANDOM_NUMBERS_TO_GENERATE];
    fill_array(_rdrand64_step, rand_array);
}

$ ~/dev/gcc/bin/gcc -march=haswell -O2 rdrand.c 
/usr/bin/ld: /tmp/ccTlQIsV.o: in function `main':
rdrand.c:(.text.startup+0x8): undefined reference to `_rdrand64_step'
collect2: error: ld returned 1 exit status

$ ~/dev/gcc/bin/gcc --version                  
gcc (GCC) 11.0.1 20210325 (experimental)
Copyright (C) 2021 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

Happens in C++ too, including passing as a template parameter.

^ permalink raw reply	[flat|nested] 19+ messages in thread

end of thread, other threads:[~2023-06-14 19:11 UTC | newest]

Thread overview: 19+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-04-09 17:10 [Bug c/100005] New: undefined reference to `_rdrand64_step' thiago at kde dot org
2021-04-09 17:15 ` [Bug c/100005] " redi at gcc dot gnu.org
2021-04-09 17:20 ` segher at gcc dot gnu.org
2021-04-09 17:27 ` segher at gcc dot gnu.org
2021-04-09 18:05 ` thiago at kde dot org
2021-04-09 18:07 ` jakub at gcc dot gnu.org
2021-04-09 18:11 ` thiago at kde dot org
2021-04-09 18:13 ` jakub at gcc dot gnu.org
2021-04-09 18:23 ` jakub at gcc dot gnu.org
2021-04-09 18:59 ` hjl.tools at gmail dot com
2021-04-09 20:27 ` [Bug target/100005] " jakub at gcc dot gnu.org
2021-04-12  8:05 ` rguenth at gcc dot gnu.org
2021-04-12 15:19 ` thiago at kde dot org
2021-04-12 15:26 ` jakub at gcc dot gnu.org
2021-04-12 15:37 ` thiago at kde dot org
2021-04-12 15:42 ` jakub at gcc dot gnu.org
2021-09-29  8:36 ` pinskia at gcc dot gnu.org
2021-09-29  8:36 ` pinskia at gcc dot gnu.org
2023-06-14 19:11 ` pinskia at gcc dot gnu.org

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).