darlinghq / darling

Darwin/macOS emulation layer for Linux
http://www.darlinghq.org
GNU General Public License v3.0
11.55k stars 446 forks source link

Unhandled ioctl on compiled Darling on Docker - Debian Bookworm (12) / Ubuntu Mantic (23.10) / Ubuntu Jammy (22.04) #1460

Open humble-desser opened 11 months ago

humble-desser commented 11 months ago

Expected Result What did you expect to happen?

Make swift print a basic "hello multiverse" script code without taking around 1min and 28s to execute. The same happened to swiftc command.

Actual Result What did happen?

After installing Command Line Tools, I tried to run swift command and it took a while and after giving an error "Passing thru unhandled ioctl 0xC00C6924 on fd 3" the code ran just fine, but it took around 1min+ or so. After the error occurs, compilation/execution of the code will happen just fine and the following execution will go faster. When exited darling, the problem will occur again and it

Steps To Reproduce

  1. Install docker (intel/amd chipset x64)
  2. copy the following code to a Dockerfile and run docker build -t darling_bookwork .
FROM debian:bookworm

RUN export DEBIAN_FRONTEND=noninteractive; apt update -y && apt upgrade -y  && \
apt install -y cmake automake clang-15 bison flex libfuse-dev libudev-dev \
pkg-config libc6-dev-i386 gcc-multilib libcairo2-dev libgl1-mesa-dev curl \
libglu1-mesa-dev libtiff5-dev libfreetype6-dev git git-lfs libelf-dev libxml2-dev \ 
libegl1-mesa-dev libfontconfig1-dev libbsd-dev libxrandr-dev libxcursor-dev libgif-dev \
libavutil-dev libpulse-dev libavformat-dev libavcodec-dev libswresample-dev libdbus-1-dev \
libxkbfile-dev libssl-dev libstdc++-12-dev llvm-dev libcap2-bin fuse wget python3-pip  python3-venv

SHELL ["/bin/bash", "-ec"]

WORKDIR /deleteme

RUN git clone -j8 --recursive https://github.com/darlinghq/darling.git

WORKDIR /deleteme/darling

RUN git lfs install && \
    git pull && \
    git submodule update --init --recursive 

RUN tools/uninstall 

RUN mkdir build

WORKDIR /deleteme/darling/build

RUN cmake -DTARGET_i386=OFF ..

RUN make -j8
RUN make -j8 install

RUN rm -rf /deleteme 
  1. Navigate to the folder where Dockerfile is located and type: docker build -t darling_bookworm .
  2. Grab a coffee and a really nice book to read then let the thing run for a while.
  3. Then when the image is built, type the following:
  4. docker run -it --privileged -v folder_containing_command_line_tools_pkg:/tools darling_bookworm bash
  5. inside the bash shell type the following to set up darling prefix and overlay stuff so it does not crash:
    
    mkdir -p /root/overlay && \
    mount -t tmpfs -o size=100% tmpfs /root/overlay &&\
    export DPREFIX=/root/overlay/.darling
>7. Type: darling shell
>8. installer -pkg [point_to_where_your_command_line_tools_pkg_file] -target /
>9. Create a test.swift file with "print("Hello Multiverse")" 
>10. Type: swift test.swift 
>11. Observe how long it takes to just print a Hello. 
>12. Note the error -> Passing thru unhandled ioctl 0xC00C6924 on fd [x]

**System Information**
What system are you using?

Host Machine:

uname -a

Linux a1032b333343 6.1.0-14-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.1.64-1 (2023-11-30) x86_64 GNU/Linux

docker --version

Docker version 20.10.24+dfsg1, build 297e128

Debian Bookworm Docker Image / Command Line Tools version 12.3: Linux edebc14e1409 6.1.0-14-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.1.64-1 (2023-11-30) x86_64 GNU/Linux


| Software | Version |
| --- | --- |
| Linux Kernel | 6.1.0-14-amd64 |
| Darling | see dockerfile (installed 12/11/2023) |

**Tested on** 
ubuntu:jammy
ubuntu:mantic
debian:bookworm 

**Observations**

- The command line tools pre-set on darling via xcode-select --install generate the same error, but it takes less time than newer command line tools.
- After the documented error occurs, compilation of swift code will go as normal, but the error will be displayed again. The code will compile at faster speed. 
- Command Line Tools up to 12.3 will work just fine, but it will generate the same error
- Command Line tools greater than 12.3 will not work even if compiled with "different version numbers", trust me I tried!

**Extra Debugging Info**

Darling [/Volumes/SystemRoot/tools]# time swift test.swift Passing thru unhandled ioctl 0xC00C6924 on fd 4 hello multiverse!

real 1m28.430s user 1m10.756s sys 0m17.154s Darling [/Volumes/SystemRoot/tools]# time swift test.swift Passing thru unhandled ioctl 0xC00C6924 on fd 3 hello multiverse!

real 0m0.271s user 0m0.127s sys 0m0.115s

Darling [/Volumes/SystemRoot/tools]# uname -a Darwin localhost 20.6.0 Darwin Kernel Version 20.6.0 x86_64 Darling [/Volumes/SystemRoot/tools]# sw_vers ProductName: macOS ProductVersion: 11.7.4 BuildVersion: Darling

Darling [/Volumes/SystemRoot/tools]# installer -pkg CLT_13_2.pkg -target / installer: Package name is SU_TITLE installer: Installing at base path / installer: Installing selected choice SU_TITLE installer: Installing package com.apple.pkg.CLTools_Executables version 13.2.0.0.1.1637719136 (2252710 KB) installer: Extracting files makewhatis: //usr/share/man//man7/mdoc.7: No such file or directory makewhatis: //usr/share/man//man1/less.1: No such file or directory makewhatis: //usr/share/man//man1/lessecho.1: No such file or directory makewhatis: //usr/share/man//man1/more.1: No such file or directory makewhatis: //usr/share/man//man1/post-grohtml.1: No such file or directory makewhatis: //usr/share/man//man1/pre-grohtml.1: No such file or directory makewhatis: ///usr/share/man//man7/mdoc.7: No such file or directory makewhatis: ///usr/share/man//man1/less.1: No such file or directory makewhatis: ///usr/share/man//man1/lessecho.1: No such file or directory makewhatis: ///usr/share/man//man1/more.1: No such file or directory makewhatis: ///usr/share/man//man1/post-grohtml.1: No such file or directory makewhatis: ///usr/share/man//man1/pre-grohtml.1: No such file or directory installer: Installing package com.apple.pkg.CLTools_SDK_macOS12 version 13.2.0.0.1.1637719136 (537092 KB) installer: Extracting files installer: Installing package com.apple.pkg.CLTools_SDK_macOS110 version 13.2.0.0.1.1637719136 (533609 KB) installer: Extracting files installer: Installing package com.apple.pkg.CLTools_macOS_SDK version 13.2.0.0.1.1637719136 (49 KB) installer: Extracting files installer: Installation complete

Darling [/Volumes/SystemRoot/tools]# swift --version Apple Swift version 5.5.2 (swiftlang-1300.0.47.5 clang-1300.0.29.30) Target: x86_64-apple-darwin20.6.0

Darling [/Volumes/SystemRoot/tools]# ls /Library/Developer/CommandLineTools/SDKs/ MacOSX.sdk MacOSX11.3.sdk MacOSX11.sdk MacOSX12.1.sdk MacOSX12.sdk

Darling [/Volumes/SystemRoot/tools]# xcrun --show-sdk-version 12.1 Darling [/Volumes/SystemRoot/tools]# xcrun --show-sdk-build-version 21C46

Darling [/Volumes/SystemRoot/tools]# xcrun --show-sdk-platform-version xcrun: error: unable to lookup item 'PlatformVersion' from command line tools installation xcrun: error: unable to lookup item 'PlatformVersion' in SDK '/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk'

Darling [/Volumes/SystemRoot/tools]# xcrun --show-sdk-platform-path xcrun: error: unable to lookup item 'PlatformPath' from command line tools installation xcrun: error: unable to lookup item 'PlatformPath' in SDK '/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk'

ROPspecterGadget commented 1 month ago

Same observation here but for Command Line Tools version 13.2