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

Elks fails to compile on Debian 12 due to libc failing to compile. typo maybe? #2042

Open
sparky4 opened this issue Sep 28, 2024 · 72 comments
Open
Labels
bug Defect in the product

Comments

@sparky4
Copy link

sparky4 commented Sep 28, 2024

Description

  • What is expected ?
  • to compile the images
  • What is observed ?
  • it stops very VERY quickly

Configuration

  • Version (commit or release):
  • latest
  • Emulator or HW platform:
  • IBM PC

How to reproduce ?

  • Does the problem always happen ?
  • yes yes
  • List the steps to reproduce the problem.
  • try to run ./build.sh

Raw data

  • Screenshot(s):

image

  • Log file:
 *
 * You may now run `make clean` and `make` to build.

Cleaning all...
make -C libc clean
make[1]: Entering directory '/home/sparky4/p/elks/libc'
for DIR in asm ctype debug error gcc getent malloc math misc net regex stdio string system termcap termios time ; do make -C $DIR clean || exit 1; done
make[2]: Entering directory '/home/sparky4/p/elks/libc/asm'
Makefile:23: *** target pattern contains no '%'.  Stop.
make[2]: Leaving directory '/home/sparky4/p/elks/libc/asm'
make[1]: *** [Makefile:240: clean] Error 1
make[1]: Leaving directory '/home/sparky4/p/elks/libc'
make: *** [Makefile:36: clean] Error 2
Build script has terminated with error 4

Additional information
Add any other context information about the problem here.

@sparky4 sparky4 added the bug Defect in the product label Sep 28, 2024
@sparky4
Copy link
Author

sparky4 commented Sep 28, 2024

I am compiling for ibm pc

@ghaerr
Copy link
Owner

ghaerr commented Sep 28, 2024

It seems there may be an incompatibility with the make you are running? Can you run make --version? My version of make is GNU v3.81. It seems the error is occurring quite quickly during make clean. Try that alone to confirm.

@sparky4
Copy link
Author

sparky4 commented Sep 28, 2024

C:\home\sparky4\p\elks> make --version
GNU Make 4.3
Built for x86_64-pc-linux-gnu
Copyright (C) 1988-2020 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later http://gnu.org/licenses/gpl.html
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

@ghaerr
Copy link
Owner

ghaerr commented Sep 28, 2024

This is quite strange; have you tried building before using exactly this method? I am trying to ascertain whether this is a new issue, or perhaps something to do with Debian 12.

Are you running Debian or Windows? I see your path is C:\home\sparky4\p\elks: that's Windows isn't it? The ELKS build is completely untested on Windows. I found the following post explaining that having a backslash in your PATH can cause this problem.

Can you try a simple make clean, then make, to see if that works? If not, then we're likely dealing with incompatibility with your system using Windows-style pathnames separated with backslashes; I won't have a fix for that.

@sparky4
Copy link
Author

sparky4 commented Sep 28, 2024

oh the prompt thing is a custom one dont worry the actual pwd is

C:\home\sparky4\p\elks> pwd
/home/sparky4/p/elks

@sparky4
Copy link
Author

sparky4 commented Sep 29, 2024

i think it's a new issue. i was able to compile it before. i dont know what happened the last few months. i just cannot make libc anymore

@toncho11
Copy link
Contributor

toncho11 commented Sep 29, 2024

If this is a fresh install of Debian then you need to do something like that in the beginning: apt install build-essential or remove your old copy of elks source and git clone again.

@toncho11
Copy link
Contributor

I am using WSL (Windows Subsystem for Linux)/Ubuntu 20. I did git pull and I managed to compile ELKS on the second time. First time there was some error, but it works for me.

@floriangit
Copy link
Contributor

I'm on Debian 12 as well. Same make version as well. Works. It does not look like ELKS build uses your (exotic) $PS1 to set something odd, but I'm not sure about it much, so maybe try to change it to debian default (and have a clean git clone of ELKS as toncho11 mentioned).

@ghaerr
Copy link
Owner

ghaerr commented Sep 29, 2024

It does not look like ELKS build uses your (exotic) $PS1 to set something odd, but I'm not sure about it much, so maybe try to change it to debian default

Agree, I would try changing the prompt, just in case.

@sparky4
Copy link
Author

sparky4 commented Sep 29, 2024

oh
ok ill do that

@sparky4
Copy link
Author

sparky4 commented Sep 29, 2024

image
nope still not compiling

@ghaerr
Copy link
Owner

ghaerr commented Sep 29, 2024

Are you running ./build.sh or make clean? The latter is preferred. It also looks like perhaps you may not have configured ELKS. The preferred way to do this is:

$ make menuconfig
(check that .config exists)
$ make clean
$ make

Don't run ./build.sh, it may be contributing to the problem?

@ghaerr
Copy link
Owner

ghaerr commented Sep 29, 2024

I would also run the above without any fancy prompt - it looks like you may be running a prompt with a linefeed in it? Try with standard PS1= to eliminate variables, since both @toncho11 and @floriangit are saying this is working fine for them.

I see you got an earlier "ELKS is not configured yet" as well as an error in "Keymaps" directory... it appears as though the build.sh script is continuing and not stopping with errors, which will contribute to the problem. You might want to do as @toncho11 suggested and remove everything and start with a git clone or git pull from scratch, and then only use "make" as described above, no shell scripts.

@sparky4
Copy link
Author

sparky4 commented Sep 29, 2024

ok ill do that

@sparky4
Copy link
Author

sparky4 commented Sep 30, 2024

image

@sparky4
Copy link
Author

sparky4 commented Sep 30, 2024

image

@ghaerr
Copy link
Owner

ghaerr commented Sep 30, 2024

You're still running a shell script. That's not 'make clean' by itself.

@ghaerr
Copy link
Owner

ghaerr commented Sep 30, 2024

Nonetheless, something is definitely wrong with the build environment. I don't know what it is, and I cannot duplicate it since I don't have a Windows or Linux box.

@ghaerr
Copy link
Owner

ghaerr commented Sep 30, 2024

The screenshots don't show enough history for me to see what you are doing. I will need a complete execution history in order to debug more.
It is possible that the cross development environment is improper, because that is more closely connected to the C library build. You might try 'make kimage' to attempt a kernel only build.
I also need you to tell me the results of the explicit instructions that I gave you a couple posts ago.

@tyama501
Copy link
Contributor

tyama501 commented Oct 1, 2024

I had a chance to download debian-12.7.0-amd64-DVD-1.iso.
I may try to install it later.

@tyama501
Copy link
Contributor

tyama501 commented Oct 1, 2024

Hello from Debian 12.7. OK, I got the system up.
I will try to get elks environment later this week.

@sparky4
Copy link
Author

sparky4 commented Oct 1, 2024

let me build the kernel then

@sparky4
Copy link
Author

sparky4 commented Oct 1, 2024

it is working! :D

@ghaerr
Copy link
Owner

ghaerr commented Oct 1, 2024

If it is now working, I suspect the problem was/is that you were running ./build.sh, a shell script that doesn't work with WSL, while make, make clean or make kimage works. Please confirm.

@sparky4
Copy link
Author

sparky4 commented Oct 1, 2024

make and make clean never worked but make kimage works just fine

@tyama501
Copy link
Contributor

tyama501 commented Oct 1, 2024

make kimage is only for kernel, right?

@sparky4
Copy link
Author

sparky4 commented Oct 1, 2024

yeah it seems

@tyama501
Copy link
Contributor

tyama501 commented Oct 2, 2024

Hi @sparky4

Are you using build.sh in the repository root or
are you using tools/build.sh?

I am now following steps here that uses tools/build.sh
https://github.com/ghaerr/elks/blob/master/BUILD.md

@tyama501
Copy link
Contributor

tyama501 commented Oct 3, 2024

Have you tried this?
cp -a ibmpc-1440.config .config
make menuconfig
make clean
make

@tyama501
Copy link
Contributor

tyama501 commented Oct 3, 2024

One more thing.

git status

can show modified files.

Some files may failed while merging when git pull.

@sparky4
Copy link
Author

sparky4 commented Oct 3, 2024

yeah i did the copy the config file i am compiling it rn!

@ghaerr
Copy link
Owner

ghaerr commented Oct 3, 2024

Thanks for the printenv output @sparky4. I was hoping to see something abnormal in PATH=, but it looks OK.

yeah i did the copy the config file i am compiling it rn!

I take that to mean you can compile with make kimage but not make clean?

clean:
        rm -f *.o *.a *.d

Did you try the above change, detailed in my post above?

Can you try changing your prompt using export PS1=sparky and then running make clean?

The only other item that is a unfamiliar is SHELL=Bourne, rather than SHELL=/bin/sh or something like that. Can you change to BASH Shell somehow, or is Bourne the WSL option?

@sparky4
Copy link
Author

sparky4 commented Oct 4, 2024

hmmm i think it is make itself being problematic.. i tried on both machines

@sparky4
Copy link
Author

sparky4 commented Oct 4, 2024

ill try sh... but i think it's make itself

@sparky4
Copy link
Author

sparky4 commented Oct 5, 2024

oh

cd /home/sparky4/p/elks; \
( \
	echo CREATE libc/build-ml/elkslibc/medium/regparmcall/libc.a.tmp; \
	for s in libc/build-ml/elkslibc/medium/regparmcall/asm/out.a libc/build-ml/elkslibc/medium/regparmcall/ctype/out.a libc/build-ml/elkslibc/medium/regparmcall/debug/out.a libc/build-ml/elkslibc/medium/regparmcall/error/out.a libc/build-ml/elkslibc/medium/regparmcall/gcc/out.a libc/build-ml/elkslibc/medium/regparmcall/getent/out.a libc/build-ml/elkslibc/medium/regparmcall/malloc/out.a libc/build-ml/elkslibc/medium/regparmcall/math/out.a libc/build-ml/elkslibc/medium/regparmcall/misc/out.a libc/build-ml/elkslibc/medium/regparmcall/net/out.a libc/build-ml/elkslibc/medium/regparmcall/regex/out.a libc/build-ml/elkslibc/medium/regparmcall/stdio/out.a libc/build-ml/elkslibc/medium/regparmcall/string/out.a libc/build-ml/elkslibc/medium/regparmcall/system/out.a libc/build-ml/elkslibc/medium/regparmcall/termcap/out.a libc/build-ml/elkslibc/medium/regparmcall/termios/out.a libc/build-ml/elkslibc/medium/regparmcall/time/out.a; \
		do echo ADDLIB "$s"; done; \
	echo SAVE \
) | ia16-elf-ar -M
ia16-elf-ar: libc/build-ml/elkslibc/medium/regparmcall/asm/out.a: No such file or directory
make[2]: *** [Makefile:123: /home/sparky4/p/elks/libc/build-ml/elkslibc/medium/regparmcall/libc.a] Error 9
make[2]: Leaving directory '/home/sparky4/p/elks/libc'
make[1]: *** [Makefile:200: all] Error 2
make[1]: Leaving directory '/home/sparky4/p/elks/libc'
make: *** [Makefile:11: all] Error 2
Build script has terminated with error 5

@sparky4
Copy link
Author

sparky4 commented Oct 5, 2024

#
# Automatically generated by make menuconfig: don't edit.
#


#
# Kernel & Hardware
#


#
# System
#

CONFIG_ARCH_IBMPC=y
# CONFIG_ARCH_8018X is not set
# CONFIG_ARCH_PC98 is not set
# CONFIG_HW_COMPAQFAST is not set
# CONFIG_HW_MK88 is not set
CONFIG_HW_VGA=y
CONFIG_HW_SERIAL_FIFO=y

#
# Kernel settings
#

CONFIG_BOOTOPTS=y
CONFIG_ASYNCIO=y
CONFIG_CPU_USAGE=y
CONFIG_TIME_RTC_LOCALTIME=y
# CONFIG_TRACE is not set
# CONFIG_TIMER_INT0F is not set
# CONFIG_TIMER_INT1C is not set
# CONFIG_ROMCODE is not set
CONFIG_FARTEXT_KERNEL=y

#
# Networking Support
#

CONFIG_SOCKET=y
# CONFIG_NANO is not set
CONFIG_INET=y
# CONFIG_UNIX is not set

#
# Filesystem Support
#

CONFIG_MINIX_FS=y
# CONFIG_ROMFS_FS is not set
CONFIG_FS_FAT=y
CONFIG_FS_EXTERNAL_BUFFER=y
CONFIG_FS_NR_EXT_BUFFERS=64
# CONFIG_FS_XMS_BUFFER is not set
CONFIG_EXEC_COMPRESS=y
CONFIG_EXEC_OS2=y
CONFIG_EXEC_MMODEL=y

#
# Drivers
#


#
# Block device drivers
#

CONFIG_BLK_DEV_BFD=y
CONFIG_BLK_DEV_FD=y
CONFIG_TRACK_CACHE=y
# CONFIG_BLK_DEV_BFD_HARD is not set
CONFIG_BLK_DEV_BHD=y
# CONFIG_IDE_PROBE is not set
CONFIG_ASYNCIO=y
CONFIG_BLK_DEV_RAM=y
CONFIG_RAMDISK_SEGMENT=0
CONFIG_RAMDISK_SECTORS=128
CONFIG_BLK_DEV_SSD_NONE=y
# CONFIG_BLK_DEV_SSD_TEST is not set
# CONFIG_BLK_DEV_SSD_SD8018X is not set
CONFIG_BLK_DEV_CHAR=y

#
# Character device drivers
#

CONFIG_CONSOLE_DIRECT=y
# CONFIG_CONSOLE_BIOS is not set
# CONFIG_CONSOLE_8018X is not set
# CONFIG_CONSOLE_HEADLESS is not set
CONFIG_KEYBOARD_SCANCODE=y
# CONFIG_CONSOLE_DUAL is not set
CONFIG_CONSOLE_SERIAL=y
CONFIG_EMUL_ANSI=y
# CONFIG_KEYMAP_BE is not set
# CONFIG_KEYMAP_DE is not set
# CONFIG_KEYMAP_DV is not set
# CONFIG_KEYMAP_ES is not set
# CONFIG_KEYMAP_FR is not set
# CONFIG_KEYMAP_IT is not set
# CONFIG_KEYMAP_SE is not set
# CONFIG_KEYMAP_UK is not set
CONFIG_KEYMAP_US=y
CONFIG_CHAR_DEV_RS=y
CONFIG_CHAR_DEV_LP=y
CONFIG_CHAR_DEV_MEM=y
CONFIG_PSEUDO_TTY=y

#
# Network device drivers
#

CONFIG_ETH=y
CONFIG_ETH_NE2K=y
CONFIG_ETH_WD=y
CONFIG_ETH_EL3=y

#
# Userland
#

# CONFIG_APPS_BY_IMAGESZ is not set
CONFIG_APP_ASH=y
CONFIG_APP_SASH=y
CONFIG_APP_DISK_UTILS=y
CONFIG_APP_FILE_UTILS=y
CONFIG_APP_SH_UTILS=y
CONFIG_APP_SYS_UTILS=y
CONFIG_APP_ELVIS=y
CONFIG_APP_MINIX1=y
CONFIG_APP_MINIX2=y
CONFIG_APP_MINIX3=y
CONFIG_APP_MISC_UTILS=y
CONFIG_APP_TUI=y
CONFIG_APP_NANOX=y
CONFIG_APP_BASIC=y
CONFIG_APP_SCREEN=y
CONFIG_APP_CRON=y
CONFIG_APP_OTHER=y
CONFIG_APP_TEST=y
# CONFIG_APP_BUSYELKS is not set
CONFIG_APP_KTCP=y
# CONFIG_APP_MAN_PAGES is not set
CONFIG_SYS_DEFSHELL_SASH=y
# CONFIG_SYS_NO_BININIT is not set

#
# Target image
#

# CONFIG_IMG_MINIX is not set
CONFIG_IMG_FAT=y
# CONFIG_IMG_ROM is not set
# CONFIG_IMG_FD2880 is not set
CONFIG_IMG_FD1440=y
# CONFIG_IMG_FD1232 is not set
# CONFIG_IMG_FD1200 is not set
# CONFIG_IMG_FD720 is not set
# CONFIG_IMG_FD360 is not set
# CONFIG_IMG_HD is not set
CONFIG_IMG_DEV=y
CONFIG_IMG_BOOT=y
CONFIG_APPS_COMPRESS=y
CONFIG_IMG_EXTRA_IMAGES=y

this is my build config i tried the default one and it failed too

@sparky4
Copy link
Author

sparky4 commented Oct 5, 2024

i think the issue is i think how libc make files are kinda strange

@sparky4
Copy link
Author

sparky4 commented Oct 6, 2024

make clean works now but make fails we are making progress! <3

@sparky4
Copy link
Author

sparky4 commented Oct 6, 2024

nvm there is issues with the libc makefiles

@tyama501
Copy link
Contributor

tyama501 commented Oct 8, 2024

Hello @ghaerr

The default mformat in Debian 12.7 is 4.0.32, so it seems that current fd1232.img cannot be created (as we already know).
Not easy to install older version so I tried modifying some parameters.
It seems that there is no error if -L is removed. (-M might be better for -S since M is for logical sector size.)
I haven't looked difference or tried the image since there is no PC-98 emulator on this PC yet.
I will do that later.

image

@ghaerr
Copy link
Owner

ghaerr commented Oct 8, 2024

Hello @tyama501,

Thanks for your report. I can't quite remember exactly why we couldn't use one of the later versions of mformat for ELKS, but if you learn another way of formatting a floppy, even just for 1232k, that would be great, as that could be changed in image/Make.defs for PC-98 which would then work on Debian 12.7 and elsewhere. I'll look further into this after you have learned more, thank you!

@tyama501
Copy link
Contributor

The fd1232.img created by mformat 4.0.32 without -L could boot,
but the second FAT position and the root directory position moved.
The total 2464k, and df Free 1528 38% are not correct, so it seems that I need to try other values.

(Above one is the new image)
elks_mformat_4 0 32_df

elks_,mformat_4 0 32_root_dir

@tyama501
Copy link
Contributor

tyama501 commented Oct 12, 2024

I manually edited the BPB Total Sector16bits from 0x09A0 to 0x04D0 (0x09A0 / 2 = 1232) by the binary editor.
The elks could recognize total 1232K, and df value looks correct. Does it use this value to calculate free space?
elks_mformat_4 0 32_mod_TotalSec16

@ghaerr
Copy link
Owner

ghaerr commented Oct 12, 2024

The elks could recognize total 1232K, and df value looks correct. Does it use this value to calculate free space?

Yes, the FAT12/FAT16 filesystem will use the Total Sector 16-bit value as the maximum number of sectors contained in the filesystem (FAT32 uses the later 32-bit total sector field).

I haven't had time to look into the differences yet between the mformat versions, sorry. What way are you currently thinking might work to use a later version of mformat with options, or would there need to be a separate "mformat-fix" program required to make this work, at this point?

@tyama501
Copy link
Contributor

Hello @ghaerr

I have been trying to replace the value by dd after the image is created but the somehow escape sequence in the make.image does not work.

Neither
echo -en "\xD0\x04"
nor
printf "\xD0\x04"
does not work.

Do you have idea to create the binary data?

@ghaerr
Copy link
Owner

ghaerr commented Oct 13, 2024

Neither
echo -en "\xD0\x04"
nor
printf "\xD0\x04"
does not work.

When you say "does not work" - what does the binary map show at the data location you're trying to modify? I presume you're trying something like printf "..." | dd skip=... of=fd1232.img?

Do you have idea to create the binary data?

It would be quite easy to write a C program to do so, much like how setboot.c modifies the BPB. I suppose you could add an option to setboot that would correct the problem.

Actually, I see Make.images uses setboot $(TARGET_FILE) -K -F $(BPB) $(FD_FAT_BOOT) for FD1232, and the -K option specifics 1K block size. This (or another new option like -T 1232) option could also (re)write the BPB total sectors16 field, and then the problem would be automatically taken care of for FD1232.

If we go with a setboot.c modification, are the mformat options the same or different than 4.0.23? That is, can we use the 4.0.23 paramaters with a later version of mformat and then just run setboot -K to fix it, or will the mformat options have to be different for later version?

@tyama501
Copy link
Contributor

In printf case the character \ (5C) and x (78) are used. I forgot about echo case but it is strange. Probably some built in echo -e cannot be used.

I will look setboot later.

-L 2 need to be changed to -L4 (or removing the option)
That will take unnecessary 2 additional sectors for each FAT but it would work for the older version too(I think...

@sparky4
Copy link
Author

sparky4 commented Oct 13, 2024

[sparky4@lappy4]$ make --version
GNU Make 4.3
Built for x86_64-pc-linux-gnu
Copyright (C) 1988-2020 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

@ghaerr
Copy link
Owner

ghaerr commented Oct 14, 2024

Hello @tyama501,

The default mformat in Debian 12.7 is 4.0.32, so it seems that current fd1232.img cannot be created

I have been looking into this, and mtools is quite complicated, and still haven't found out exactly why later versions than mtools-4.0.23 don't work for our project. I remember experimenting years ago but of course it is time-consuming to figure out exactly where the mtools maintainers break image formats that used to work.

So I a thinking that, instead of hacking our own tools like setboot to fix mtools-4.0.32 etc, maybe a better solution would be to build mtools-4.0.23 from source within ELKS elks/tools/mformat locally, and thus a working version always be available when building ELKS. While Debian 12.7 has chosen 4.0.32, I see that we are dependent on the automated Github CI build using 4.0.23. Should that be updated, our automated build would break.

What do you think? The potential risk is that mtools may not build on certain systems without changes, but we can always manage that with bug reports. This would also save you from diving into hex debuggers trying to (also) figure out exactly what is wrong with newer versions of mformat for PC-98 1232k disk image creation.

Thank you!

@tyama501
Copy link
Contributor

Hello @ghaerr

I haven't seen the dependencies but that would be fine for me if it is posible.
It is GPL3 and no license issue right?
Thank you!

@ghaerr
Copy link
Owner

ghaerr commented Oct 15, 2024

Hello @tyama501,

I have added mtools-4.0.23 in PR #2074 which should allow you to build PC-98 images on Debian 12.7 without changing mformat parameters. If you can test it here, that would be great.

Thank you!

@tyama501
Copy link
Contributor

Hello @ghaerr ,

I could build bootable 1232 image by the debian without changing parameters.
Thank you for adding the mtools!

image

@ghaerr
Copy link
Owner

ghaerr commented Oct 16, 2024

Hello @tyama501,

Thanks for testing! I'm glad it all works, it looked like a lot of work for both of us to re-analyze all the issues relating to floppy disk formats and the buggy mtools distribution(s).

Thank you!

@sparky4
Copy link
Author

sparky4 commented Oct 19, 2024

i still cannot compile libc

@rafael2k
Copy link

Here in my Debian 12, build.sh works fine.

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

No branches or pull requests

7 participants
@rafael2k @toncho11 @sparky4 @ghaerr @tyama501 @floriangit and others