TUD-OS / NRE

NOVA runtime environment (official branch)
GNU General Public License v2.0
33 stars 12 forks source link

Probably a simple nre/SConstruct question #58

Closed lonnietc closed 3 years ago

lonnietc commented 3 years ago

Hi Nils,

Hope that all is well.

I have been working on trying to modify the nre/SConstruct file so that I can get the musl-1.2.2 code integrated into building up a libmusl.a library.

For this, I was trying to rearrange the existing nre/include directory to move all of the C++ headers into a "nre/include/nre" directory and put the musl clib includes in a "nre/include/musl" directory so as not to mix the 2 sets of headers.

For this and along with a number of other changes to try and build the "libmusl.a" file from the sources, I am having troubles in getting the CPATH and CPPPATH environmental variables to play nicely.

In the nre/SCronstruct there is a section:

env = Environment( CXXFLAGS = '-Wall -Wextra -ansi -std=c++0x -msse2', CFLAGS = '-Wall -Wextra -std=c99 -msse2',

without "-z max-page-size=0x1000" ld produces really large binaries for x86_64, because it

# aligns to 2MiB (not only in virtual memory, but also in the binary)
LINKFLAGS = '-nostartfiles -Wl,--no-undefined -static -Wl,-static -static-libgcc'
    + ' -Wl,-z,max-page-size=0x1000',
ENV = {
    'PATH' : crossdir + "/bin:" + os.environ['PATH'],
    # required for colored outputs
    'HOME' : os.environ['HOME'],
    'TERM' : os.environ['TERM']
    },
CPPPATH = '#include/nre',
CPATH = '#include/musl',
LD = cross + '-ld',
AS = cross + '-as',
AR = cross + '-ar',
RANLIB = cross + '-ranlib',

)

I added the CPATH = '#include/musl', to try and get it to look in the "include/musl" space for the headers snice if I move the nre headers from "include" to "include/nre" just by themselves then they compile fine without the musl library changes added.

I also tried to extend the CPPPATH variable to be:

CPPPATH = '#include/nre:#include/musl',

but that does not work as well.

If I just take the default "nre/SConstruct" (i.e. without any changes for musl) and change the CPPPATH to be "#include/nre" and move the default NRE headers then that simple changes relocates the NRE headers just fine.

The problem seems to be how to easily add an INCLUDE search path extension to that I can start working on getting the musl source code to find the musl headers down the "include/musl" path.

Any simple ideas without having to edit all of the NRE or MUSL headers?

I know that this should be a simple SConstruct fix, but so far cannot get it to work the way that I want. Cheers

lonnietc commented 3 years ago

I temporarily solved it by hard coding an "-I" include line in the CXX flags line.

Will find a better solution later so that I can get it on an environment variable later. Cheers

Nils-TUD commented 3 years ago

There is no CPATH variable. CPPPATH does not stand for "C++ Path", but for "C Preprocessor Path". Therefore, it is used for both C and C++ :)

So, extending CPPPATH is correct, but you did it in the wrong way. SCons expects a list of paths, not a string with multiple paths separated by colon.

Try the following: CPPPATH = ['#include/nre', '#include/musl']

lonnietc commented 3 years ago

Thanks for getting back to me on this.

Did not think about that approach and have only used SCons a little in the past, although mostly Makefiles. Time to learn SCons, I think since it looks very powerful.

Right now, I am starting to work out the merging of the NRE (libstdc++): pthread.cc, stdlib.cc, string.cc with nre/includes for cstdlib, cstring, and pthread.h with their matching functions in the MUSL Clib sections to keep the functions that are NRE dependent to talk to NOVA.

I will keep the NRE versions of most of those functions (above) since they seem to be dependent upon other NRE headers which means that they may be tied into others as well and then modify the other OS dependent functions in a step-by-step way.

May take some time, and hope that it goes reasonably well.

Truly appreciate all of the help that you have provided, my friend.

lonnietc commented 3 years ago

As an update, I am now able to compile up and use "some" of the musl Clib libraries.

Still working on porting a lot of things and hopefully will get it done in the near future since I want to be able to compile up some existing applications over to the NRE platform, but still a long ways from that step.

Also, started working on trying to port over the Bhyve VMM over to NOVA+NRE and we will see how that goes since there are many things that need re-worked. Not sure that I can complete this task, but am going to try.

Cheers.