public inbox for newlib@sourceware.org
 help / color / mirror / Atom feed
* undefined reference to '__builtin_mul_overflow'
@ 2022-02-25 11:24 Jordi Sanfeliu
  2022-02-25 12:03 ` Sebastian Huber
  0 siblings, 1 reply; 3+ messages in thread
From: Jordi Sanfeliu @ 2022-02-25 11:24 UTC (permalink / raw)
  To: newlib

Hello,

I'm upgrading to Newlib 4.1.0 version (from Newlib 3.2.0) in my own 
hobby operating system FiwixOS for i386, and after a successful build 
with GCC 4.7.4 and Binutils 2.23.2, I found that I'm unable to compile a 
simple C program:

# cat test.c
#include <stdio.h>

int main(void)
{
	printf("newlib version %s\n", _NEWLIB_VERSION);
	return 0;
}

# gcc -o test test.c
/usr/lib/gcc/i686-pc-fiwix/4.7.4/../../../../i686-pc-fiwix/lib/libc.a(lib_a-callocr.o): 
In function `_calloc_r':
/mnt/builds/build-newlib-4.1.0.final/i386-fiwix/newlib/libc/stdlib/../../../../../newlib-4.1.0/newlib/libc/stdlib/mallocr.c:3210: 
undefined reference to `__builtin_mul_overflow'
collect2: error: ld returned 1 exit status


Looking in the Newlib 4.2.0 source code, I'm indeed unable to find the 
function '__builtin_mul_overflow'. This is what 'grep' says:

# grep -r __builtin_mul_overflow *
newlib/libc/stdlib/mallocr.c:  if 
(__builtin_mul_overflow((INTERNAL_SIZE_T) n, (INTERNAL_SIZE_T) 
elem_size, &sz))
newlib/libc/stdlib/nano-mallocr.c:    if (__builtin_mul_overflow (n, 
elem, &bytes))
newlib/libc/stdlib/reallocarray.c:	if (__builtin_mul_overflow (nmemb, 
size, &bytes))

There are references to it but I don't see where this function is defined.

Any idea what I'm missing here?
Regards.

-- 
Jordi Sanfeliu
FIBRANET Network Services Provider
https://www.fibranet.cat

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

* Re: undefined reference to '__builtin_mul_overflow'
  2022-02-25 11:24 undefined reference to '__builtin_mul_overflow' Jordi Sanfeliu
@ 2022-02-25 12:03 ` Sebastian Huber
  2022-02-25 15:07   ` Jordi Sanfeliu
  0 siblings, 1 reply; 3+ messages in thread
From: Sebastian Huber @ 2022-02-25 12:03 UTC (permalink / raw)
  To: Jordi Sanfeliu, newlib

Hello Jordi,

On 25/02/2022 12:24, Jordi Sanfeliu via Newlib wrote:
> I'm upgrading to Newlib 4.1.0 version (from Newlib 3.2.0) in my own 
> hobby operating system FiwixOS for i386, and after a successful build 
> with GCC 4.7.4 and Binutils 2.23.2, I found that I'm unable to compile a 
> simple C program:
> 
> # cat test.c
> #include <stdio.h>
> 
> int main(void)
> {
>      printf("newlib version %s\n", _NEWLIB_VERSION);
>      return 0;
> }
> 
> # gcc -o test test.c
> /usr/lib/gcc/i686-pc-fiwix/4.7.4/../../../../i686-pc-fiwix/lib/libc.a(lib_a-callocr.o): 
> In function `_calloc_r':
> /mnt/builds/build-newlib-4.1.0.final/i386-fiwix/newlib/libc/stdlib/../../../../../newlib-4.1.0/newlib/libc/stdlib/mallocr.c:3210: 
> undefined reference to `__builtin_mul_overflow'

this builtin is available since GCC 5. Maybe you should update your GCC 
version or implement __builtin_mul_overflow() in your operating system.

-- 
embedded brains GmbH
Herr Sebastian HUBER
Dornierstr. 4
82178 Puchheim
Germany
email: sebastian.huber@embedded-brains.de
phone: +49-89-18 94 741 - 16
fax:   +49-89-18 94 741 - 08

Registergericht: Amtsgericht München
Registernummer: HRB 157899
Vertretungsberechtigte Geschäftsführer: Peter Rasmussen, Thomas Dörfler
Unsere Datenschutzerklärung finden Sie hier:
https://embedded-brains.de/datenschutzerklaerung/

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

* Re: undefined reference to '__builtin_mul_overflow'
  2022-02-25 12:03 ` Sebastian Huber
@ 2022-02-25 15:07   ` Jordi Sanfeliu
  0 siblings, 0 replies; 3+ messages in thread
From: Jordi Sanfeliu @ 2022-02-25 15:07 UTC (permalink / raw)
  To: newlib

Hello Sebastian,

I appreciate your quick reply.


On 2/25/22 13:03, Sebastian Huber wrote:

> this builtin is available since GCC 5. Maybe you should update your GCC 
> version or implement __builtin_mul_overflow() in your operating system.
> 

Understood, time to upgrade the toolchain.

Just curiosity, what if I comment out these lines that are using that 
function?

Does this will suppose a malfunction later? I mean, is this function 
required to have a working Newlib 4.1.0 implementation?

Thanks.

-- 
Jordi Sanfeliu
FIBRANET Network Services Provider
https://www.fibranet.cat

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

end of thread, other threads:[~2022-02-25 15:07 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-02-25 11:24 undefined reference to '__builtin_mul_overflow' Jordi Sanfeliu
2022-02-25 12:03 ` Sebastian Huber
2022-02-25 15:07   ` Jordi Sanfeliu

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