Giter Club home page Giter Club logo

Comments (8)

fwsGonzo avatar fwsGonzo commented on June 12, 2024

Hey, the reason for that was because .bss was initialized pretty late. So, I just pushed a change where .bss (basically, the whole section needs to be zeroed) will now be initialized early on in the assembly.

See: 0064e3d

macOS is not exactly supported, as I don't have a mac. Still, hope that helps. I don't really expect this setup to work on mac, but it would be nice if it did.

from barebones.

hexabyte23 avatar hexabyte23 commented on June 12, 2024

Yes, that fix section problem, but after installing NASM with brew, got this new errors:

Jarvis2:barebones thierry$ ./run.sh
~/Dev/barebones/machines/default ~/Dev/barebones
~/Dev/barebones/machines/default/build ~/Dev/barebones/machines/default ~/Dev/barebones
-- Configuring done
-- Generating done
-- Build files have been written to: /Users/thierry/Dev/barebones/machines/default/build
[ 25%] Built target tinyprintf
[ 37%] Built target exceptions
[ 51%] Building CXX object src/CMakeFiles/kernel.dir/kernel/tls.cpp.o
[ 51%] Building C object src/CMakeFiles/kernel.dir/crt/c_stubs.c.o
[ 51%] Building ASM_NASM object src/CMakeFiles/kernel.dir/kernel/start.asm.o
[ 51%] Building CXX object src/CMakeFiles/kernel.dir/kernel/elf.cpp.o
/Users/thierry/Dev/barebones/src/kernel/start.asm:17: error: unknown section name

/Users/thierry/Dev/barebones/src/kernel/start.asm:17: error: segment name `.multiboot' not recognized
make[2]: *** [src/CMakeFiles/kernel.dir/kernel/start.asm.o] Error 1
make[2]: *** Waiting for unfinished jobs....
In file included from /Users/thierry/Dev/barebones/src/kernel/elf.cpp:1:
/Users/thierry/Dev/barebones/src/kernel/elf.hpp:2:10: fatal error: 'elf.h' file
not found
#include <elf.h>
^~~~~~~
/Users/thierry/Dev/barebones/src/crt/c_stubs.c:4:10: fatal error: 'link.h' file
not found
#include <link.h>
^~~~~~~~
1 error generated.
make[2]: *** [src/CMakeFiles/kernel.dir/crt/c_stubs.c.o] Error 1
/Users/thierry/Dev/barebones/src/kernel/tls.cpp:9:45: error: argument to
'section' attribute is not valid for this target: mach-o section specifier
requires a segment and section separated by a comma
struct tls_table tls attribute((section(".data")));
^
1 error generated.
make[2]: *** [src/CMakeFiles/kernel.dir/kernel/tls.cpp.o] Error 1
1 error generated.
make[2]: *** [src/CMakeFiles/kernel.dir/kernel/elf.cpp.o] Error 1
make[1]: *** [src/CMakeFiles/kernel.dir/all] Error 2
make: *** [all] Error 2

from barebones.

fwsGonzo avatar fwsGonzo commented on June 12, 2024

What happens if you try building with Clang? You will probably have to download elf.h and link.h yourself, as I dont think I will be adding those manually into the repo. Although, I could do without link.h and just create the prototype for the stub myself, and then do provide elf.h. In the end, you do need a compiler that builds for linux and not macOS. Clang can do that with -target.

from barebones.

hexabyte23 avatar hexabyte23 commented on June 12, 2024

I clean build dir then call run.sh again, and in fact it seems that I already used Clang compiler, but Apple version one...

Jarvis2:barebones thierry$ ./run.sh
~/Dev/barebones/machines/default ~/Dev/barebones
~/Dev/barebones/machines/default/build ~/Dev/barebones/machines/default ~/Dev/barebones
-- The C compiler identification is AppleClang 10.0.1.10010046
-- The CXX compiler identification is AppleClang 10.0.1.10010046
-- Check for working C compiler: /Library/Developer/CommandLineTools/usr/bin/cc
-- Check for working C compiler: /Library/Developer/CommandLineTools/usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /Library/Developer/CommandLineTools/usr/bin/c++
-- Check for working CXX compiler: /Library/Developer/CommandLineTools/usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- The ASM_NASM compiler identification is NASM
-- Found assembler: /usr/local/bin/nasm
-- Configuring done
-- Generating done
-- Build files have been written to: /Users/thierry/Dev/barebones/machines/default/build
Scanning dependencies of target exceptions
Scanning dependencies of target tinyprintf
[ 7%] Building C object ext/CMakeFiles/tinyprintf.dir/tinyprintf/tinyprintf.c.o
[ 7%] Creating directories for 'exceptions'
[ 11%] Performing download step (download, verify and extract) for 'exceptions'
-- Downloading...
dst='/Users/thierry/Dev/barebones/machines/default/build/exceptions/src/exceptions.zip'
timeout='none'
-- Using src='https://github.com/fwsGonzo/barebones/releases/download/exceptions/exceptions.zip'
[ 14%] Linking C static library libtinyprintf.a
[ 14%] Built target tinyprintf
Scanning dependencies of target kernel
[ 25%] Building C object src/CMakeFiles/kernel.dir/hw/serial1.c.o
[ 25%] Building C object src/CMakeFiles/kernel.dir/crt/c_abi.c.o
[ 25%] Building C object src/CMakeFiles/kernel.dir/kernel/kernel_start.c.o
/Users/thierry/Dev/barebones/src/kernel/kernel_start.c:6:13: warning: unused function '__init_paging' [-Wunused-function]
static void __init_paging()
^
1 warning generated.
[ 29%] Building C object src/CMakeFiles/kernel.dir/crt/c_stubs.c.o
[ 33%] Building C object src/CMakeFiles/kernel.dir/crt/heap.c.o
[ 37%] Building C object src/CMakeFiles/kernel.dir/crt/malloc.c.o
/Users/thierry/Dev/barebones/src/crt/c_stubs.c:4:10: fatal error: 'link.h' file not found
#include <link.h>
^~~~~~~~
1 error generated.
make[2]: *** [src/CMakeFiles/kernel.dir/crt/c_stubs.c.o] Error 1
make[2]: *** Waiting for unfinished jobs....
/Users/thierry/Dev/barebones/src/crt/malloc.c:23:13: warning: 'sbrk' is deprecated [-Wdeprecated-declarations]
b = sbrk(word_align(sizeof(struct chunk)));
^
/Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk/usr/include/unistd.h:585:1: note: 'sbrk' has been explicitly
marked deprecated here
__deprecated __WATCHOS_PROHIBITED __TVOS_PROHIBITED
^
/Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk/usr/include/sys/cdefs.h:176:40: note: expanded from macro
'__deprecated'
#define __deprecated attribute((deprecated))
^
/Users/thierry/Dev/barebones/src/crt/malloc.c:70:22: warning: 'sbrk' is deprecated [-Wdeprecated-declarations]
Chunk newc = sbrk(length);
^
/Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk/usr/include/unistd.h:585:1: note: 'sbrk' has been explicitly
marked deprecated here
__deprecated __WATCHOS_PROHIBITED __TVOS_PROHIBITED
^
/Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk/usr/include/sys/cdefs.h:176:40: note: expanded from macro
'__deprecated'
#define __deprecated attribute((deprecated))
^
/Users/thierry/Dev/barebones/src/crt/malloc.c:88:46: warning: 'sbrk' is deprecated [-Wdeprecated-declarations]
if (!ptr || ptr < malloc_base() || ptr > sbrk(0)) return;
^
/Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk/usr/include/unistd.h:585:1: note: 'sbrk' has been explicitly
marked deprecated here
__deprecated __WATCHOS_PROHIBITED __TVOS_PROHIBITED
^
/Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk/usr/include/sys/cdefs.h:176:40: note: expanded from macro
'__deprecated'
#define __deprecated attribute((deprecated))
^
/Users/thierry/Dev/barebones/src/crt/malloc.c:101:9: warning: 'sbrk' is deprecated [-Wdeprecated-declarations]
sbrk(- c->size - sizeof(struct chunk));
^
/Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk/usr/include/unistd.h:585:1: note: 'sbrk' has been explicitly
marked deprecated here
__deprecated __WATCHOS_PROHIBITED __TVOS_PROHIBITED
^
/Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk/usr/include/sys/cdefs.h:176:40: note: expanded from macro
'__deprecated'
#define __deprecated attribute((deprecated))
^
/Users/thierry/Dev/barebones/src/crt/malloc.c:117:57: warning: 'sbrk' is deprecated [-Wdeprecated-declarations]
if (newptr && ptr && ptr >= malloc_base() && ptr <= sbrk(0)) {
^
/Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk/usr/include/unistd.h:585:1: note: 'sbrk' has been explicitly
marked deprecated here
__deprecated __WATCHOS_PROHIBITED __TVOS_PROHIBITED
^
/Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk/usr/include/sys/cdefs.h:176:40: note: expanded from macro
'__deprecated'
#define __deprecated attribute((deprecated))
^
5 warnings generated.
make[1]: *** [src/CMakeFiles/kernel.dir/all] Error 2
make[1]: *** Waiting for unfinished jobs....
-- [download 0% complete]
-- [download 2% complete]
-- [download 5% complete]
-- [download 7% complete]
-- [download 8% complete]
-- [download 10% complete]
-- [download 12% complete]
-- [download 13% complete]
-- [download 15% complete]
-- [download 18% complete]
-- [download 20% complete]
-- [download 23% complete]
-- [download 25% complete]
-- [download 28% complete]
-- [download 30% complete]
-- [download 33% complete]
-- [download 35% complete]
-- [download 36% complete]
-- [download 38% complete]
-- [download 40% complete]
-- [download 41% complete]
-- [download 43% complete]
-- [download 46% complete]
-- [download 48% complete]
-- [download 51% complete]
-- [download 53% complete]
-- [download 56% complete]
-- [download 58% complete]
-- [download 61% complete]
-- [download 63% complete]
-- [download 66% complete]
-- [download 68% complete]
-- [download 69% complete]
-- [download 71% complete]
-- [download 73% complete]
-- [download 74% complete]
-- [download 76% complete]
-- [download 79% complete]
-- [download 81% complete]
-- [download 84% complete]
-- [download 86% complete]
-- [download 89% complete]
-- [download 91% complete]
-- [download 94% complete]
-- [download 96% complete]
-- [download 97% complete]
-- [download 99% complete]
-- [download 100% complete]
-- verifying file...
file='/Users/thierry/Dev/barebones/machines/default/build/exceptions/src/exceptions.zip'
-- Downloading... done
-- extracting...
src='/Users/thierry/Dev/barebones/machines/default/build/exceptions/src/exceptions.zip'
dst='/Users/thierry/Dev/barebones/machines/default/build/exceptions/src/exceptions'
-- extracting... [tar xfz]
-- extracting... [analysis]
-- extracting... [rename]
-- extracting... [clean up]
-- extracting... done
[ 44%] No update step for 'exceptions'
[ 44%] No patch step for 'exceptions'
[ 48%] No configure step for 'exceptions'
[ 51%] No build step for 'exceptions'
[ 55%] No install step for 'exceptions'
[ 59%] Completed 'exceptions'
[ 59%] Built target exceptions
make: *** [all] Error 2

from barebones.

fwsGonzo avatar fwsGonzo commented on June 12, 2024

Try installing clang using brew and use that. Although, if you just want this project to work then install Ubuntu desktop in VirtualBox or some other desktop virtualization application and it should just work out of the box.

from barebones.

hexabyte23 avatar hexabyte23 commented on June 12, 2024

Yes I know that, but I thought could be cool to have source code directly compatible with MacOS. Thanks for your help fwsGonzo

from barebones.

fwsGonzo avatar fwsGonzo commented on June 12, 2024

The problem is that sections are named differently on macOS, but even so I think the ABI stuff is different too and that means there will be incompatibilities.
I removed the section attribute on the TLS structure, but there is still an error in your log that says that nasm can't access .multiboot, because there is no such section. You also don't have link.h and elf.h both of which are needed. So there is not going to be any building with APPLE defined anyway. Your best bet is to use crosstool-ng package and switch to a compiler that outputs Linux binaries, probably. :)

from barebones.

hexabyte23 avatar hexabyte23 commented on June 12, 2024

ok, I find apple compatible version of elf.h and link.h (and dependencies) in Apple site here

https://opensource.apple.com/source/dtrace/dtrace-96/sys/

AppleClang compiler are no more complains, just see how to fix .multiboot problem ... must dig in my own kernel sample I wrote few months ago

from barebones.

Related Issues (8)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.