Skip to content

Building on Debian 13 fails #14

@Jookia

Description

@Jookia

Hi there,

Building on Debian 13 or Ubuntu 26.04 fails with this error:

installing overlay-shell32 to /tmp/layer/mingw32_486-msvcrt_win98-16/AAB/thunk-host/usr/local/i686-w64-mingw32 ..
installing overlay-ucrt ..
installing overlay-ucrt to /tmp/layer/mingw32_486-msvcrt_win98-16/AAB/thunk-host/usr/local/i686-w64-mingw32 ..
installing overlay-ws2_32 ..
installing overlay-ws2_32 to /tmp/layer/mingw32_486-msvcrt_win98-16/AAB/thunk-host/usr/local/i686-w64-mingw32 ..
install ok!
Traceback (most recent call last):
  File "/mnt/mingw-lite/./main.py", line 188, in <module>
    main()
    ~~~~^^
  File "/mnt/mingw-lite/./main.py", line 176, in main
    build_AAB_compiler(ver, paths, config)
    ~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^
  File "/mnt/mingw-lite/module/AAB.py", line 559, in build_AAB_compiler
    _crt_host(ver, paths, config)
    ~~~~~~~~~^^^^^^^^^^^^^^^^^^^^
  File "/mnt/mingw-lite/module/AAB.py", line 311, in _crt_host
    postprocess_crt_import_libraries(
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
      ver,
      ^^^^
    ...<5 lines>...
      jobs = config.jobs,
      ^^^^^^^^^^^^^^^^^^^
    )
    ^
  File "/mnt/mingw-lite/module/alt_crt.py", line 467, in postprocess_crt_import_libraries
    result = future.result()
  File "/usr/lib/python3.13/concurrent/futures/_base.py", line 449, in result
    return self.__get_result()
           ~~~~~~~~~~~~~~~~~^^
  File "/usr/lib/python3.13/concurrent/futures/_base.py", line 401, in __get_result
    raise self._exception
  File "/usr/lib/python3.13/concurrent/futures/thread.py", line 59, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/mnt/mingw-lite/module/alt_crt.py", line 239, in process_single_import_library
    dll, sym = read_short_import_object(data, ver)
               ~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^
  File "/mnt/mingw-lite/module/alt_crt.py", line 94, in read_short_import_object
    assert(len(strings) == 3 and len(strings[2]) == 0)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AssertionError

I changed the code to disable threading and print some debugging. This particular case is:

file /tmp/layer/mingw32_486-msvcrt_win98-16/AAB/thunk-host/usr/local/i686-w64-mingw32/lib/libalias-short-msvcrt-os.a
entry msvcrt.dll

Note that to try builidng you must also disable overlayfs in the code, at least on my computer that was required. Here is my WIP patch:

diff --git a/module/alt_crt.py b/module/alt_crt.py
index 68266d8..57ff06a 100644
--- a/module/alt_crt.py
+++ b/module/alt_crt.py
@@ -91,6 +91,7 @@ def read_short_import_object(data: bytes, ver: BranchProfile) -> Tuple[str, Norm
   kind = ImportKind(data[18] & 0b11)
 
   strings = data[20:].split(b'\x00')
+  print(len(strings) == 3 and len(strings[2]) == 0)
   assert(len(strings) == 3 and len(strings[2]) == 0)
   sym_name = strings[0].decode()
   if ver.arch == '32':
@@ -220,6 +221,7 @@ def process_single_import_library(
               overlay_force_override.add(remove_imp_prefix(sym.name[prefix_len:], ver))
 
     if overlay.alias:
+      print(f"file {overlay.alias}")
       with libarchive.file_reader(str(overlay.alias)) as archive:
         for entry in archive:
           data = b''
@@ -236,6 +238,7 @@ def process_single_import_library(
               pass
             elif data[:4] == b'\x00\x00\xff\xff':
               # normal import symbol
+              print(f"entry {entry}")
               dll, sym = read_short_import_object(data, ver)
               if dll not in dynamic:
                 dynamic[dll] = ImportSymbols(set(), set())
@@ -264,6 +267,7 @@ def process_single_import_library(
       overlay = None
       dynamic = {}
 
+  print(f"file {imp0}")
   with libarchive.file_reader(str(imp0)) as archive:
     for entry in archive:
       data = b''
@@ -283,6 +287,7 @@ def process_single_import_library(
           pass
         elif data[:4] == b'\x00\x00\xff\xff':
           # normal import symbol
+          print(f"entry {entry}")
           dll, sym = read_short_import_object(data, ver)
 
           if sym.name in overlay_symbols:
@@ -401,7 +406,7 @@ def process_single_import_library(
 
     if len(static) > 0:
       subprocess.run(
-        ['llvm-ar', 'x', imp0, *static],
+        ['i686-w64-mingw32-ar', 'x', imp0, *static],
         cwd = tmpdir,
         check = True,
       )
@@ -414,7 +419,7 @@ def process_single_import_library(
       f.write(''.join(mri_content))
     with open(f'{tmpdir}/mri') as f:
       subprocess.run(
-        ['llvm-ar', '-M'],
+        ['i686-w64-mingw32-ar', '-M'],
         cwd = tmpdir,
         check = True,
         stdin = f,
@@ -435,7 +440,7 @@ def postprocess_crt_import_libraries(
 
   thunk_map: Dict[str, Dict[str, str]] = {}
 
-  with ThreadPoolExecutor(max_workers = jobs) as executor:
+  with ThreadPoolExecutor(max_workers = 1) as executor:
     futures = []
     lib_names = []
 
@@ -455,19 +460,13 @@ def postprocess_crt_import_libraries(
             overlay.alias = thunk_lib_dir / alias_file_name
 
         imp = crt_lib_dir / file_name
-        futures.append(executor.submit(
-          process_single_import_library,
+        thunk_map[lib_name] = process_single_import_library(
           ver, overlay, imp0, imp, assert_thunk_free, assert_thunk_revertible,
-        ))
+        )
         lib_names.append(lib_name)
       else:
         shutil.copy2(imp0, crt_lib_dir / file_name)
 
-    for lib_name, future in zip(lib_names, futures):
-      result = future.result()
-      if result:
-        thunk_map[lib_name] = result
-
   return thunk_map
 
 def generate_thunk_revert_map(thunk_map: Dict[str, Dict[str, str]], output_path: Path):
diff --git a/module/util.py b/module/util.py
index efc8fb5..35a230f 100644
--- a/module/util.py
+++ b/module/util.py
@@ -269,40 +269,17 @@ def overlayfs_ro(merged: Union[Path, str], lower: Sequence[Union[Path, str]]):
   # here we only detect WSL 1 (WSL 2 is considered “genuine Linux”)
   #   WSL 1: 4.4.0-19041-Microsoft
   #   WSL 2: 6.6.87.2-microsoft-standard-WSL2
-  if os.uname().release.endswith('-Microsoft'):
-    subprocess.run(['mount', '-t', 'tmpfs', 'none', merged], check = True)
-    try:
-      # https://www.kernel.org/doc/html/v6.18/filesystems/overlayfs.html
-      #   The specified lower directories will be stacked
-      #   beginning from the rightmost one and going left.
-      # so we copy from right to left.
-      for layer in reversed(lower):
-        shutil.copytree(layer, merged, dirs_exist_ok = True)
-      yield
-    finally:
-      subprocess.run(['umount', merged], check = False)
-  else:
-    if len(lower) == 1:
-      subprocess.run([
-        'mount',
-        '--bind',
-        lower[0],
-        merged,
-        '-o', 'ro',
-      ], check = True)
-    else:
-      lowerdir = ':'.join(map(str, lower))
-      subprocess.run([
-        'mount',
-        '-t', 'overlay',
-        'none',
-        merged,
-        '-o', f'lowerdir={lowerdir}',
-      ], check = True)
-    try:
-      yield
-    finally:
-      subprocess.run(['umount', merged], check = False)
+  subprocess.run(['mount', '-t', 'tmpfs', 'none', merged], check = True)
+  try:
+    # https://www.kernel.org/doc/html/v6.18/filesystems/overlayfs.html
+    #   The specified lower directories will be stacked
+    #   beginning from the rightmost one and going left.
+    # so we copy from right to left.
+    for layer in reversed(lower):
+      shutil.copytree(layer, merged, dirs_exist_ok = True)
+    yield
+  finally:
+    subprocess.run(['umount', merged], check = False)
 
 def remove_info_main_menu(prefix: Path):
   info_main_menu = prefix / 'share/info/dir'

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions