error: implicit declaration of function 'assert'

720 views
Skip to first unread message

Dmitry Kurbatov

unread,
Dec 18, 2018, 5:08:29 AM12/18/18
to embox-devel
Hi,

I'm trying to port embox to riscv's qemu-sifive_e platform. Now I'm struggling with build system. I have this config:

package genconfig

configuration conf
{
    include embox
.arch.riscv.kernel.boot
    include embox
.arch.riscv.kernel.arch



   
// temporary disabled irqs
    include embox
.driver.interrupt.no_interrupts
    include embox
.kernel.no_irq


    include embox
.driver.serial.sifive_uart(base_addr=0x10013000,baud_rate=115200,clock_freq=32000000)
    include embox
.driver.diag(impl="embox__driver__serial__sifive_uart")

   
// copied from multiclet's config
    include embox
.kernel.cpu.no_bkl
    include embox
.kernel.cpu.no_cpudata
    include embox
.compat.libc.math_libm_none
    include embox
.compat.libc.type
    include embox
.compat.libc.str
    include embox
.compat.libc.assert
    include embox
.kernel.Kernel

    include embox
.framework.LibFramework
}

next I run:

make confload-riscv/qemu-sifive-e
make

But get an error:

src/kernel/irq_static.c: In function 'irq_attach':
src
/kernel/irq_static.c:28:2: error: implicit declaration of function 'assert' [-Werror=implicit-function-declaration]

As I understand, I include `assert` func with deirective `include embox.compat.libc.assert` in build config, but that's not working.

What I'm doing wrong?

wbr,
Dmitry

Anton Kozlov

unread,
Dec 18, 2018, 5:16:26 AM12/18/18
to embox...@googlegroups.com
> But get an error:
>
> src/kernel/irq_static.c: In function 'irq_attach':
> src/kernel/irq_static.c:28:2: error: implicit declaration of function 'assert' [-Werror=implicit-function-declaration]
>
> As I understand, I include `assert` func with deirective `include embox.compat.libc.assert` in build config, but that's not working.
>
The error is generated by compiler.
irq_static uses assert macro, assert macro is defined in some header
that can be included (as you have necessary module included in .conf,
that's correct).
I beleive after you add

#include <assert.h>

in irq_static.c, the issue will go away.

I'm not sure why the issue remain unnoticed until now. Maybe because
kernel/irq.h included assert before and now it doesn't. Or irq.h is
different one that was usually used with irq_static

-- Anton

Alex Kalmuk

unread,
Dec 18, 2018, 5:18:44 AM12/18/18
to embox...@googlegroups.com
I think it's a bug since no_irq depends on irq_static somewhy. We will fix it in a moment.

Best regards,
Alex

вт, 18 дек. 2018 г. в 13:16, Anton Kozlov <drako...@gmail.com>:
--
You received this message because you are subscribed to the Google Groups "embox-devel" group.
To unsubscribe from this group and stop receiving emails from it, send an email to embox-devel...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Alex Kalmuk

unread,
Dec 18, 2018, 5:28:30 AM12/18/18
to embox...@googlegroups.com
We merged the corresponding fix into master with this PR. Dmitry, please, try it now.

вт, 18 дек. 2018 г. в 13:18, Alex Kalmuk <alexk...@gmail.com>:

Dmitry Kurbatov

unread,
Dec 18, 2018, 6:08:58 AM12/18/18
to embox-devel
Thanks for fast reply!

I've tryed and all goes well till next error :)

I've slightly changed config

package genconfig

configuration conf
{
    include embox
.arch.riscv.kernel.boot
    include embox
.arch.riscv.kernel.arch

   
// temporary disabled irqs
    include embox
.driver.interrupt.no_interrupts
    include embox
.kernel.no_irq

    include embox
.driver.serial.sifive_uart(base_addr=0x10013000,baud_rate=115200,clock_freq=32000000)
    include embox
.driver.diag(impl="embox__driver__serial__sifive_uart")

   
// copied from multiclet's config
    include embox
.kernel.cpu.no_bkl
    include embox
.kernel.cpu.no_cpudata
//    include embox.compat.libc.math_libm_none
    include embox
.compat.libc.math_builtins
    include embox
.compat.libc.stdio.print(support_floating=0)

   
    include embox
.compat.libc.type
    include embox
.compat.libc.str
    include embox
.compat.libc.assert
    include embox
.kernel.Kernel

//    include embox.framework.LibFramework
}



and got an error:

src/compat/libc/math/math_builtins.c:26:8: error: conflicting types for built-in function 'roundl' [-Werror=builtin-declaration-mismatch]

If I use `embox.compat.libc.math_libm_none` I get this error:

src/compat/libc/stdio/printf_impl.c:13:10: fatal error: math.h: No such file or directory

Is there maybe minimal build config for a first boot stage?

wbr,
Dmitry




Alex Kalmuk

unread,
Dec 18, 2018, 6:49:52 AM12/18/18
to embox...@googlegroups.com
I am afraid we do not have a suitable minimal build to start with, since some of them are broken. But after discussing among ourselves, we decided to prepare a minimal general build right now. I hope today it will be ready. Concerning errors with math library, we will try to fix math_builtins right now.

вт, 18 дек. 2018 г. в 14:09, Dmitry Kurbatov <d...@dimcha.ru>:

Anton Bondarev

unread,
Dec 18, 2018, 7:03:00 AM12/18/18
to embox...@googlegroups.com
I fixed math_builtins
Now it in master. Please checkout and check it.

вт, 18 дек. 2018 г. в 14:49, Alex Kalmuk <alexk...@gmail.com>:

Alex Kalmuk

unread,
Dec 18, 2018, 11:59:20 AM12/18/18
to embox...@googlegroups.com
Dmitry, we added x86/minimal and arm/minimal templates. You can try one of them, maybe it will help in making your own build.

вт, 18 дек. 2018 г. в 15:03, Anton Bondarev <anton.bon...@gmail.com>:

Dmitry Kurbatov

unread,
Dec 18, 2018, 2:19:47 PM12/18/18
to embox-devel
Thanks a lot for fast help!

I fetched latest commits and tried in different variations but get a stable result - "cannot stat libgcc.a":

$ make
make
[4]: Nothing to be done for 'all'.
make
[4]: '/home/dk/devel/other/embox/build/base/gen/embox_gcc_env.sh' is up to date.
cp
"$(riscv32-unknown-elf-gcc -pipe --debug-prefix-map=`pwd`= --debug-prefix-map=./= -fno-strict-aliasing -fno-common -Wall -Werror -Wundef -Wno-trigraphs -Wno-char-subscripts -Wformat -std=gnu99 -g -O0 -march=rv32imac -mabi=ilp32 -mcmodel=medany -Wno-misleading-indentation -Wno-nonnull-compare -print-file-name=libgcc.a | sed $'s/$//')" ./build/base/obj/third-party/lib/libgcc
cp
: cannot stat libgcc.a’: No such file or directory
make
[4]: *** [build/base/gen/third-party/lib/libgcc/libgcc.a.rule.mk:17: build/base/obj/third-party/lib/libgcc/libgcc.a] Error 1
make
[3]: *** [mk/build.mk:23: build] Error 2
make
[2]: *** [mk/load.mk:41: build] Error 2
make
[1]: *** [mk/main.mk:30: build] Error 2
make
: *** [Makefile:37: all] Error 2

in `./build/base/obj/third-party/lib/libgcc` only two files: empty.d  empty.o

by the way, when I tried to build x86/minimal I got an error:

make[4]: Nothing to be done for 'all'.
make
[4]: '/home/dk/devel/other/embox/build/base/gen/embox_gcc_env.sh' is up to date.
make
[4]: Nothing to be done for 'all'.
EMBOX_GCC_LINK
=full ./mk/extbld/arch-embox-gcc ./mk/extbld/toolchain_test.c -o ./build/base/obj/toolchain_test
/usr/bin/ld: error in ./build/base/obj/embox.o(.eh_frame); no .eh_frame_hdr table will be created.
./build/base/obj/embox.o: In function `print_i':
src/compat/libc/stdio/printf_impl.c:114: undefined reference to `
__umoddi3'
src/compat/libc/stdio/printf_impl.c:117: undefined reference to `__udivdi3'

collect2
: error: ld returned 1 exit status
make
[4]: *** [mk/extbld/toolchain.mk:76: build/base/obj/toolchain_test] Error 1
make
[3]: *** [mk/build.mk:24: build] Error 2
make
[2]: *** [mk/load.mk:41: build] Error 2
make
[1]: *** [mk/main.mk:30: build] Error 2
make
: *** [Makefile:37: all] Error 2

even with `embox.compat.libc.stdio.print(support_floating=0)` but libgcc.a is present.


I reduced my changes to minimum:

// based on x86/minimal template

package genconfig

configuration conf
{
    include embox
.arch.riscv.kernel.boot
    include embox
.arch.riscv.kernel.
arch

   
/* There is no interrupts */
    include embox
.arch.generic.interrupt_stub
    include embox
.driver.interrupt.no_interrupts
    include embox
.kernel.no_irq

    include embox
.kernel.stack(stack_size=0x2000)

   
/* Use writing/reading to/from memory instead of using real serial port */
    include embox
.driver.diag.mem_diag
    include embox
.driver.diag(impl="embox__driver__diag__mem_diag")

   
/* Tell printf() do not support floating point */
    include embox
.compat.libc.stdio.print(support_floating=0)

    include embox
.kernel.critical
    include embox
.compat.libc.math_builtins
    include embox
.kernel.spinlock(spin_debug = false)
}

I got a few mybuild errors also:

 BUILDMODEL
(Unknown):: error: No abstract realization: embox.arch.libarch.
(Unknown):: error: No abstract realization: embox.arch.locore.
 BUILDGEN build

maybe it's important.

any ideas?

--
wbr,
Dmitry

Alex Kalmuk

unread,
Dec 18, 2018, 3:24:28 PM12/18/18
to embox...@googlegroups.com
src/compat/libc/stdio/printf_impl.c:114: undefined reference to `__umoddi3'
Please, try to install gcc-multilib

> (Unknown):: error: No abstract realization: embox.arch.libarch.
> (Unknown):: error: No abstract realization: embox.arch.locore.
I think this can be normal to start, since the first thing we need is some boot code to call kernel_start() somehow. Then, kernel_start will call printk("\nEmbox kernel start\n"); and as soon as you implemented your serial driver you probably will see that. And then, of course, setjmp, exceptions, interrupts, etc. are required to be implemented.


вт, 18 дек. 2018 г. в 22:19, Dmitry Kurbatov <d...@dimcha.ru>:
--

Dmitry Kurbatov

unread,
Dec 19, 2018, 2:48:19 AM12/19/18
to embox-devel
Thanks for hint!

It seems like I screwed it up - my toolchain was compiled with incomplete 32-bit support. Compilers are for 32/64bit but there are no 32-bit libs. I just got a latest toolchain from https://github.com/riscv/riscv-gnu-toolchain and configure it like `./configure --prefix=/opt/riscv --enable-multilib --enable-linux`. After that build became succesful.

Thanks for help all involved!

wbr,
Dmitry

Alex Kalmuk

unread,
Dec 19, 2018, 4:54:35 AM12/19/18
to embox...@googlegroups.com
It's nice to know you succeed in building!
> ./configure --prefix=/opt/riscv --enable-multilib --enable-linux
It looks like this command configures Linux specific toolchain, and I would propose to try "--disable-linux" since in Embox we use "bare metal" toolchain.

ср, 19 дек. 2018 г. в 10:48, Dmitry Kurbatov <d...@dimcha.ru>:
--
Reply all
Reply to author
Forward
0 new messages