Skip to contentSkip to conversation

How to build mini-OS with libc support, like Newlib?

Help Lele MA 3 participants 6 messages Sep 2, 2014 – Sep 6, 2014

lore
Share & tools
lore

Lele MA

author
#0 lore raw

Hi all,

I am going to write my own applications in miniOS, and find it can't call the function xs_open which is available only if HAVE_LIBC is defined.

According to the README in mini-os, it suggests seeing the stubdom/ directory. But I still can not find how to do it.

So, does anyone know how to build mini-os with much better libc support?

If Newlib can be used to build mini-os, how to do it? Do I have to compile a cross-compiler first?

Any help will be appreciated. Thanks in advance!

--

Best Regards,
Lele MA

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

#1 lore raw
Quoted 2 lines · Lele MA, le Tue 02 Sep 2014 15:20:32 +0800, a écrit :

If Newlib can be used to build mini-os, how to do it? Do I have to compile a cross-compiler first?

Yes. But this all already handled by the Makefile in stubdom/, and see the end of README about the c-stubdom target which builds the c/ directory.

Samuel

author
#2 lore raw
Quoted 9 lines · Samuel Thibault
Quoted 2 lines · Lele MA, le Tue 02 Sep 2014 15:20:32 +0800, a écrit :

If Newlib can be used to build mini-os, how to do it? Do I have to compile a cross-compiler first?

Yes. But this all already handled by the Makefile in stubdom/, and see the end of README about the c-stubdom target which builds the c/ directory.

Thank you so much! It is great to build newlib so conveniently. But when I run 'make c-stubdom' in stubdom/, it yields:

make: *** No rule to make target `mini-os-x86_64-c', needed by
`c-stubdom'. Stop"

Do you have any idea about how this happen?

BTW, after building xen, there is a new directory named "newlib-x86_64/' in stubdom/. I am a newbie to newlib and don't know what's this exactly. Is it the newlib that a stubdomain can use as the libc?

My xen version is 4.4.0 and dom-0 is Ubuntu-12.04. Thank you for your patience!

Best regards,
Lele MA

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

#3 lore raw
Quoted 12 lines · Lele Ma, le Tue 02 Sep 2014 17:36:36 +0800, a écrit :
Quoted 9 lines · Samuel Thibault
Quoted 2 lines · Lele MA, le Tue 02 Sep 2014 15:20:32 +0800, a écrit :

If Newlib can be used to build mini-os, how to do it? Do I have to compile a cross-compiler first?

Yes. But this all already handled by the Makefile in stubdom/, and see the end of README about the c-stubdom target which builds the c/ directory.

Quoted 7 lines

Thank you so much! It is great to build newlib so conveniently. But when I run 'make c-stubdom' in stubdom/, it yields:

make: *** No rule to make target `mini-os-x86_64-c', needed by
`c-stubdom'. Stop"

Do you have any idea about how this happen?

It's been years since I have had a look at that build system :)

Apparently the c target somehow gets disabled, but you can add it by hand in

TARGETS=$(STUBDOM_TARGETS) c

Quoted 4 lines

BTW, after building xen, there is a new directory named "newlib-x86_64/' in stubdom/. I am a newbie to newlib and don't know what's this exactly. Is it the newlib that a stubdomain can use as the libc?

That's it, yes.

Samuel

#4 lore raw
Quoted 19 lines · 在 2014-09-02 06:55:35,"Samuel Thibault" <[email protected]> 写道:
Quoted 18 lines · Lele Ma, le Tue 02 Sep 2014 17:36:36 +0800, a écrit :
Quoted 9 lines · Samuel Thibault
Quoted 2 lines · Lele MA, le Tue 02 Sep 2014 15:20:32 +0800, a écrit :

If Newlib can be used to build mini-os, how to do it? Do I have to compile a cross-compiler first?

Yes. But this all already handled by the Makefile in stubdom/, and see the end of README about the c-stubdom target which builds the c/ directory.

Thank you so much! It is great to build newlib so conveniently. But when I run 'make c-stubdom' in stubdom/, it yields:

make: *** No rule to make target `mini-os-x86_64-c', needed by
`c-stubdom'. Stop"

Quoted 10 lines
Quoted 1 line

Do you have any idea about how this happen?

It's been years since I have had a look at that build system :)

Apparently the c target somehow gets disabled, but you can add it by hand in

TARGETS=$(STUBDOM_TARGETS) c

Samuel, Thank you so much, it helps!

But I have to disable the CONFIG_TEST in /stubdom/c/minios.cfg, or it yields multiple definition:

      /media/wind/lab/xen/xen/xen-4.4.0/stubdom/mini-os-x86_64-c/test.o: In function `app_main':
      /media/wind/lab/xen/xen/xen-4.4.0/extras/mini-os/test.c:542: multiple definition of `app_main'
      /media/wind/lab/xen/xen/xen-4.4.0/stubdom/mini-os-x86_64-c/main.o:/media/wind/lab/xen/xen/xen-4.4.0/extras/mini-os/main.c:187: first defined here

Does the stubdomain allow only one app_main to run?
I have tried adding "__attribute__((weak))" before "int app_main()" in main.c, so that it will be replaced by the new definition in test.c. It builds well but the VM cannot be created with yielding erros.

Another question confuses me a lot. The c-stub domain exit immediately after prints the "Hello world" defined in /stubdom/c/main.c. And the console functions defined in /extras/mini-os/console/console.c has no effect at all. So, how can I enable the console functions?

The configurations and Makefiles overwhelm me. Any help would be appreciated.

Apologies if questions are too naive.

Best regards,
Lele MA

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

#5 lore raw
Quoted 1 line · Lele MA, le Fri 05 Sep 2014 16:40:11 +0800, a écrit :

Does the stubdomain allow only one app_main to run?

Well, yes, sure, just like you can't have several main function in a C program. This is apparently a spurious change, I have submitted a patch removing it, thanks for the report.

Quoted 1 line

Another question confuses me a lot. The c-stub domain exit immediately after prints the "Hello world" defined in /stubdom/c/main.c.

Yes, that's just a hello world example.

Quoted 1 line

And the console functions defined in /extras/mini-os/console/console.c has no effect at all. So, how can I enable the console functions?

Which function, precisely?

The C stubdom is supposed to provide you with a C environment, so you should just use printf.

Samuel