!ayCRiZriCVtuCUpeLp:nixos.org

Nix Cross Compiling

578 Members
125 Servers

You have reached the beginning of time (for this room).


SenderMessageTime
26 Mar 2025
@stephen:crabsin.spacen3tcathmm20:23:09
@stephen:crabsin.spacen3tcatI added the -fno-stack-protector and it unfortunately didn't help any of the errors as far as I can tell20:23:26
@stephen:crabsin.spacen3tcatshould I continue trying to remove more hardening options?20:23:32
@k900:0upti.meK900 Try to just set hardeningDisable = "all" in your shell 20:24:08
@stephen:crabsin.spacen3tcat
{
  inputs = {
    nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
    flake-utils.url = "github:numtide/flake-utils?ref=main";
  };

  outputs =
    inputs:
    inputs.flake-utils.lib.eachDefaultSystem (
      system:
      let
        pkgs = inputs.nixpkgs.legacyPackages.${system};
        pkgsCrossM68k = import "/home/stephen/src/k900/nixpkgs" {
          system = "x86_64-linux"; crossSystem = "m68k-unknown-none-elf";
        };
      in
        {
          devShells.default = pkgs.mkShell {
            packages = (
              with pkgs; [
                minipro
                gnumake
                xxd

                pkgsCrossM68k.stdenv.cc
              ]
            );

            hardeningDisable = ["all"];
          };
        }
    );
}

This is what my flake.nix looks like now but I'm still getting the same errors when building

20:27:15
@stephen:crabsin.spacen3tcat

I am not sure if this helps or not, but I also tried the following:

	/nix/store/ix4mrsayc4i5d61ar59fh1p33nkxchqv-m68k-unknown-none-elf-gcc-13.2.0/bin/m68k-unknown-none-elf-gcc -T Linker.ld -o os.bin -O2 -m68000 -Wall -Wextra -nostdlib start.o main.o -fno-PIE ${OBJ} -ffreestanding `/nix/store/ix4mrsayc4i5d61ar59fh1p33nkxchqv-m68k-unknown-none-elf-gcc-13.2.0/bin/m68k-unknown-none-elf-gcc -m68000 -print-libgcc-file-name -ffreestanding`

I think this skips the wrapper, but I'm still getting the same error messages

20:31:31
@k900:0upti.meK900Hm 20:33:11
@k900:0upti.meK900Are you sure this is the unwrapped one? 20:33:24
@stephen:crabsin.spacen3tcat

I did

bat /nix/store/9j1jlb4921jrl730rlxjk0sba7d415ni-m68k-unknown-none-elf-gcc-wrapper-13.2.0/bin/m68k-unknown-none-elf-gcc

Which had the following: 28 │ [[ "/nix/store/ix4mrsayc4i5d61ar59fh1p33nkxchqv-m68k-unknown-none-elf-gcc-13.2.0/bin/m68k-unknown-none-elf-gcc" = *++ ]] && isCxx=1 || isCxx=0

So I stole the path from there

20:34:48
@k900:0upti.meK900Oh yeah that makes sensd20:35:18
@stephen:crabsin.spacen3tcat
> file /nix/store/ix4mrsayc4i5d61ar59fh1p33nkxchqv-m68k-unknown-none-elf-gcc-13.2.0/bin/m68k-unknown-none-elf-gcc
/nix/store/ix4mrsayc4i5d61ar59fh1p33nkxchqv-m68k-unknown-none-elf-gcc-13.2.0/bin/m68k-unknown-none-elf-gcc: ELF 64-bit LSB executable, x86-64, version 1 (GNU/Linux), dynamically linked, interpreter /nix/store/7jiqcrg061xi5clniy7z5pvkc4jiaqav-glibc-2.38-27/lib/ld-linux-x86-64.so.2, for GNU/Linux 3.10.0, not stripped
20:35:18
@k900:0upti.meK900Have you cleaned the build directory? 20:35:35
@k900:0upti.meK900You probably need to rebuild the whole thing 20:35:40
@k900:0upti.meK900With the flags removed 20:35:45
@stephen:crabsin.spacen3tcatLike the build directory of my project?20:35:59
@stephen:crabsin.spacen3tcatoh yeah that makes sense ofc20:36:40
@k900:0upti.meK900Yeah 20:36:43
@stephen:crabsin.spacen3tcat
m68k-unknown-none-elf-gcc -T Linker.ld -o os.bin -O2 -m68000 -Wall -Wextra -nostdlib start.o main.o -fno-PIE drivers/screen.o drivers/serial.o cpu/interrupt.o cpu/interrupts.o libc/stdlib.o libc/string.o prog/mandelbrot.o prog/memtest.o prog/tty.o   -ffreestanding `m68k-unknown-none-elf-gcc -m68000 -print-libgcc-file-name -ffreestanding`
/nix/store/fmdkz68rg2al0ds776246wkzc12kva5q-m68k-unknown-none-elf-binutils-2.40/bin/m68k-unknown-none-elf-ld: main.o: in function `kmain':
main.c:(.text+0x6): undefined reference to `_GLOBAL_OFFSET_TABLE_'
collect2: error: ld returned 1 exit status

certainly less errors

20:38:25
@stephen:crabsin.spacen3tcatoh nvm my clean script doesn't clean properly20:38:42
@stephen:crabsin.spacen3tcatseems to be working now :320:38:49
@stephen:crabsin.spacen3tcatoh hell yeah I took out the hardening thing and it still works. I must have had some bad build files left over from the other day20:39:47
@stephen:crabsin.spacen3tcattyty! This has been extremely helpful for me20:39:52
@k900:0upti.meK900Yeah if you can confirm this actually works, we may want to track down some newlib folk 20:44:17
@k900:0upti.meK900And see if they will take the patch20:44:23
@stephen:crabsin.spacen3tcatI have some C code building now (well, flashing to the RAM) but yeah that is something I would love to do20:45:39
@stephen:crabsin.spacen3tcatWhere do I find newlib folks? Would I just open a PR with your change and then hopefully they will comment on it?20:45:53
@k900:0upti.meK900I think they're still on like 20:46:25
@k900:0upti.meK900CVS or some shit 20:46:27

Show newer messages


Back to Room ListRoom Version: 6