Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't compile examples by default. Rename libc to libc-unused/ #18

Merged
merged 1 commit into from
Dec 28, 2024

Conversation

ghaerr
Copy link
Owner

@ghaerr ghaerr commented Dec 28, 2024

As discussed in ghaerr/elks#2112 (comment), a top-level "make" no longer tries to build examples/, since after building the 8086 toolchain, "make c86" must be executed in the ELKS repo (discussed in ghaerr/elks#2158).

Renames libc/ to libc-unused/, since the small C library previously in 8086 toolchain has been replaced by the full ELKS C library built using "make c86" on ELKS.

@toncho11
Copy link

So it is:

make host in toolchain
make c86 in elks folder
make elks in toolchain

Problem is I need to set c86 variable for make c86.

@toncho11
Copy link

Please disable nasm build.

If I just do make in the toolchain I get:

Error! E3008: cannot open ../elks-bin/c86 : No such file or directory
Error: Linker returned a bad status
make[1]: *** [Makefile.elks:79: ../elks-bin/c86] Error 1
make[1]: Leaving directory '/root/8086-toolchain/compiler'
make: *** [Makefile:4: elks] Error 2

@toncho11
Copy link

Maybe you can do a fresh clone of the toolchain and try if it builds.

@toncho11
Copy link

toncho11 commented Dec 28, 2024

Currently make host is OK, but make elks fails with the message above.

@ghaerr
Copy link
Owner Author

ghaerr commented Dec 28, 2024

Problem is I need to set c86 variable for make c86.

You can edit libc/c86env.sh for that, and or do that at the same time you set your ELKS and OWC environments:

cd ELKS; . env.sh
cd libc; . wcenv.sh; . c86env.sh
cd ELKS
make; make own
cd TOOLCHAIN
make host
cd ELKS; make c86
cd TOOLCHAIN
make elks

You're in a first-time bootstrapping issue, which will get better once you have OW and C86 libraries built, unless you do a make clean.

Please disable nasm build.
If I just do make in the toolchain I get:
Error! E3008: cannot open ../elks-bin/c86 : No such file or directory

Let me look at that, for some reason NASM is trying to use the elks binaries. I'll push a fix ASAP, otherwise nasm/Makefile.elks and change BINDIR=../host-bin for that as well as nasm32/Makefile.elks.

@ghaerr
Copy link
Owner Author

ghaerr commented Dec 28, 2024

but make elks fails with the message above.

Good catch. It seems this has been in @rafael2k's Makefile.elks the whole time, but never was an issue since I'm running the C86 compiler from PATH, which is finding the compiler. Fix coming ASAP.

@ghaerr
Copy link
Owner Author

ghaerr commented Dec 28, 2024

It seems this has been in @rafael2k's Makefile.elks the whole time, but never was an issue since I'm running the C86 compiler from PATH, which is finding the compiler.

Oops - totally wrong on that. It @rafael2k's Makefile.elks is fine. I think the problem is that the elks-bin directory does not exist. Try "mkdir elks-bin" and see what happens.

@ghaerr
Copy link
Owner Author

ghaerr commented Dec 28, 2024

That's the problem: "mkdir -p host-bin elks-bin" required before starting. Pushing fix now.

@toncho11
Copy link

Well done! It works!!!!!!!!!!!! The only thing that does not work is make -f Makefile.elks.

There must be a tutorial like this:

#Adjust  wcenv.sh and c86env.sh
cd ELKS; . env.sh
cd libc; . wcenv.sh; . c86env.sh
cd ELKS
make; make owc
cd TOOLCHAIN
make host
cd ELKS; make c86
cd TOOLCHAIN
make elks
cd examples
make -f Makefile
make -f Makefile.elks

@toncho11
Copy link

And the Makefile in examples is the host makefile, right?

I do:

root@PC:~/8086-toolchain/examples# make -f Makefile
../host-bin/cpp86 -0 -I/root/elks/libc/include -I/root/elks/elks/include -I/root/elks/libc/include/c86  -o test.i test.c
../host-bin/c86 -g -O -bas86 -warn=4 -lang=c99 -align=yes -separate=yes -stackopt=minimum -peep=all -stackcheck=no test.i test.as
../host-bin/as86 -0 -O -j -w- -o test.o -l test.lst test.as
../host-bin/cpp86 -0 -I/root/elks/libc/include -I/root/elks/elks/include -I/root/elks/libc/include/c86  -o cprintf.i cprintf.c
../host-bin/c86 -g -O -bas86 -warn=4 -lang=c99 -align=yes -separate=yes -stackopt=minimum -peep=all -stackcheck=no cprintf.i cprintf.as
../host-bin/as86 -0 -O -j -w- -o cprintf.o -l cprintf.lst cprintf.as
../host-bin/ld86 -0 -i -L/root/elks/libc test.o cprintf.o -lc86 -o test
../host-bin/cpp86 -0 -I/root/elks/libc/include -I/root/elks/elks/include -I/root/elks/libc/include/c86  -o chess.i chess.c
../host-bin/c86 -g -O -bas86 -warn=4 -lang=c99 -align=yes -separate=yes -stackopt=minimum -peep=all -stackcheck=no chess.i chess.as
../host-bin/as86 -0 -O -j -w- -o chess.o -l chess.lst chess.as
../host-bin/ld86 -0 -i -L/root/elks/libc chess.o -lc86 -o chess
../host-bin/nasm86 -f as86 show_fonts.asm -o show_fonts.o
../host-bin/ld86 -0 -i -L/root/elks/libc show_fonts.o -o show_fonts
root@PC:~/8086-toolchain/examples# ./chess
-bash: ./chess: cannot execute binary file: Exec format error

And I get an execution error. If these are the host compiled binaries, they should work, right?

@toncho11
Copy link

The binaries of test and chess are always native ... ?
So I can not execute them on Linux.
The Makefile is used to produce them on the host.
And Makefile.elks is used when running inside ELKS?

@toncho11
Copy link

I just need to run test and chess in ELKS and verify they run as expected and we are done :)
That will be later.
binaries.zip

@ghaerr
Copy link
Owner Author

ghaerr commented Dec 29, 2024

And the Makefile in examples is the host makefile, right?
And I get an execution error. If these are the host compiled binaries, they should work, right?

You're now cross-compiling, so no, these executables are ELKS executables! If you run 'file' on them, it should say what they are:

$ file chess
chess: Linux-8086 executable not stripped

BTW, 'file' is available on ELKS itself also and knows about ELKS executables and AS86 .o files.

The binaries of test and chess are always native ... ?
So I can not execute them on Linux.

That's correct, since you are cross-compiling.

The Makefile is used to produce them on the host.
And Makefile.elks is used when running inside ELKS?

Yes, although examples/Makefile.elks has not been maintained, since I am using a different procedure for native compilation. This is yet another issue for discussion in regards to how we should distribute large ELKS images that might have the C86 toolchain and/or games on it, discussed in #2157.

I just need to run test and chess in ELKS and verify they run as expected and we are done :)

I have verified your 'chess' and 'test' - they are 100% bit identical to my versions, and run on ELKS!

There must be a tutorial like this:

I'll post what needs to be done on another thread.

@ghaerr
Copy link
Owner Author

ghaerr commented Dec 29, 2024

@toncho11, see #2159 for a detailed summary of building the 8086 toolchain and C86 libraries.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants