Conversation
6f310f2 to
e34ab0a
Compare
|
@guyush1 Do you prefere ini or toml for the like 2 configurations we currently expose for the full build? |
Toml, i liked it in rust :) |
31129d0 to
7e5d9a9
Compare
|
rebase above develop please |
src/compilation/build.py
Outdated
| self.CFLAGS.append(flag) | ||
| self.CXXFLAGS.append(flag) | ||
|
|
||
| def add_flags(self, library: "LibraryMetadata"): |
There was a problem hiding this comment.
This is a bad name for the function
Maybe something like: add_lib_search_path or something similar.
src/compilation/build.py
Outdated
| source_path: Path | ||
| commands: List[str] | ||
|
|
||
| # If relative then it's relative to the install path. |
There was a problem hiding this comment.
at least from the code, i can see the path here is ALWAYS relative to the build dir.
| # If relative then it's relative to the install path. | |
| # Relative to the build path |
There was a problem hiding this comment.
But the documentation should be comprehensive. Currently we only use it relative to the install dir, but someone could put an absolute path there. Things will work.
Changing the comment will make it less precise.
|
|
||
| env_setup: Callable[[CompilationEnv, Dict[str, str]], None] = lambda _, __: None | ||
|
|
||
| # If relative then it's relative to the install path. |
There was a problem hiding this comment.
Same here, code implies its always to the install path
| # If relative then it's relative to the install path. | |
| # Relative to install path. |
| # If relative then it's relative to the install path. | ||
| result_files: List[Path] = field(default_factory=list) | ||
|
|
||
| build_suffix: str = "" |
There was a problem hiding this comment.
i don't see why it takes a default "" construction. shouldn't that be an error we would want to discover?
There was a problem hiding this comment.
No? Most libraries don't use it. It's fine.
We only use for gdb, to differentiate full and slim builds.
src/compilation/build.py
Outdated
| def get_build_path(self, arch: CompilationArch) -> Path: | ||
| return self.source_path / f"build-{arch.value}{self.build_suffix}" | ||
|
|
||
| def get_install_path(self, arch: CompilationArch) -> Path: | ||
| return Path(self.get_build_path(arch) / self.install_path) | ||
|
|
||
| def get_missing_files(self, arch: CompilationArch) -> List[Path]: | ||
| if len(self.result_files) == 0: | ||
| return [] | ||
|
|
||
| return list(filter(lambda file: not (self.get_install_path(arch) / file).exists(), self.result_files)) |
There was a problem hiding this comment.
would be nice if it was a property instead like you did in the previous class
There was a problem hiding this comment.
For build path and install path, yes. For the missing files? No.
They can change, property isn't suitable here.
There was a problem hiding this comment.
For build path and install path, yes. For the missing files? No.
They can change, property isn't suitable here.
src/compilation/build.py
Outdated
| libraries = process_libraries(comp_env) | ||
|
|
||
| # Add libraries with dependencies | ||
| libraries["mpfr"] = LibraryMetadata( | ||
| comp_env.packages_dir / "mpfr", | ||
| commands=[ | ||
| f"../configure --enable-static --prefix={{install}} --host={{HOST}} --with-gmp={libraries["gmp"].get_install_path(comp_env.arch)}", | ||
| "make -j$(nproc)", | ||
| "make install" | ||
| ], | ||
| result_files=[Path("lib/libmpfr.a")] | ||
| ) | ||
|
|
||
| if args.build_variant == BuildVariant.FULL: | ||
| # An easy way to configure the full build without needing to modify docker arguments or | ||
| # parts of this file to ahieve the desired result. | ||
| with open(comp_env.script_dir / "full_build_conf.toml", "rb") as full_build_config_file: | ||
| build_config_dict = tomllib.load(full_build_config_file) | ||
|
|
||
| is_cross_arch_debugging = build_config_dict["full_build_cross_arch_debugging"] | ||
| is_building_python = build_config_dict["full_build_python_support"] | ||
|
|
||
| gdb_flags = [] | ||
| if is_cross_arch_debugging: | ||
| gdb_flags.extend([ | ||
| f"--enable-targets='{args.bfd_arches}'", | ||
| "--enable-64-bit-bfd", | ||
| "--disable-sim", | ||
| ]) | ||
|
|
||
| if is_building_python: | ||
| libraries["libffi"] = LibraryMetadata( | ||
| comp_env.submodules_dir / "libffi", | ||
| commands=[ | ||
| "cd .. && ./autogen.sh", | ||
| "CFLAGS='{CFLAGS} -DNO_JAVA_RAW_API' ../configure --enable-silent-rules --enable-static --disable-shared --disable-docs --host={HOST} --prefix={install}", | ||
| "make -j$(nproc)", | ||
| "make install" | ||
| ], | ||
| result_files=[Path("lib/libffi.a")] | ||
| ) | ||
| libraries["python"] = LibraryMetadata( | ||
| comp_env.submodules_dir / "cpython-static", | ||
| env_setup=python_env_setup, | ||
| # We install Python to the build path because otherwise Python breaks and sets incorrect | ||
| # paths for libhacl in python-configure. | ||
| install_path=Path("."), | ||
| commands=[ | ||
| """ | ||
| ../configure \ | ||
| --prefix={install} \ | ||
| --disable-test-modules \ | ||
| --with-ensurepip=no \ | ||
| --without-decimal-contextvar \ | ||
| --build=$(gcc -dumpmachine) \ | ||
| --host={HOST} \ | ||
| --with-build-python="/usr/bin/{python}" \ | ||
| --disable-ipv6 \ | ||
| --disable-shared | ||
| """, | ||
| "{python} ../Tools/build/freeze_modules.py", | ||
| "make regen-frozen", | ||
| "make -j$(nproc)", | ||
| "make install" | ||
| ], | ||
| result_files=[Path("bin/python3-config"), Path(f"lib/lib{comp_env.python}.a")] | ||
| ) | ||
| gdb_flags.append( | ||
| f"--with-python={libraries["python"].get_install_path(comp_env.arch) / "bin/python3-config"}", | ||
| ) | ||
| else: | ||
| gdb_flags = ["--without-python"] |
There was a problem hiding this comment.
this whole process of configuring library compilation commands does not belong in the main function.
src/compilation/build.py
Outdated
| if len(GDB_PROGRAM_SUFFIX) > 0: | ||
| gdb_flags.append("--program-suffix=" + GDB_PROGRAM_SUFFIX) | ||
|
|
||
| libraries["gdb"] = LibraryMetadata( |
src/compilation/full_build_conf.toml
Outdated
| full_build_cross_arch_debugging = true | ||
| full_build_python_support = true |
There was a problem hiding this comment.
Add headers, so instead of full_build_cross_arch_debugging we could have full_build.cross_arch_debugging and full_build.python_support.
Makefile
Outdated
| _build-%: symlink-git-packages download-packages build-docker-image | ||
| mkdir -p build | ||
| docker run $(TTY_ARG) --user $(shell id -u):$(shell id -g) \ | ||
| docker run -e GDB_PROGRAM_SUFFIX="${GDB_PROGRAM_SUFFIX}" $(TTY_ARG) --user $(shell id -u):$(shell id -g) \ |
There was a problem hiding this comment.
did this variable exist before in some way? what does it do?
There was a problem hiding this comment.
Yes - I want to package it for the AUR, but the problem is that if we just build it regularly then static gdb and regular gdb will conflict because the files will be the same.
I want to use this variable to add a suffix to the resulting binaries, removing the conflict.
There was a problem hiding this comment.
If you prefer I can add it to the build config file as an optional variable.
There was a problem hiding this comment.
If you prefer I can add it to the build config file as an optional variable.
yes please
|
fix automation as well please :) |
|
This MR will go through 2 review cycles:
|
7e5d9a9 to
8431a5c
Compare
The few differneces are that we directly install more packages (The only package that doesn't have a unique install dir is Python, which installs directly to its build-dir because otherwise module link-flags fail) and that we allow to add a suffix to the gdb files.
8431a5c to
819cb68
Compare
Closes #62