swiftlang / swiftlang/swift-corelibs-libdispatch

libdispatch compiled without frame pointers in at least in Swift 6.2, 6.1 and 6.0 on x86_64

Open
#909 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
C
Stars
2.6k
Forks
496
Avg merge
2d 6h
Merged PRs (30d)
3

Description

It appears that Swift on Linux is still compiling without frame pointers in 6.0, 6.1 and 6.2. The official docker images for for example Ubuntu 24.04 (noble) on x86_64 have this code:

Expected:
has pushq %rbp; movq %rsp, %rbp

Actual:
hasn't got push rbp; mov rsp,rbp

One-line repro from nothing: docker run -it --rm --platform linux/amd64 swift:6.2-noble lldb --batch -o 'dis -n _dispatch_sema4_wait' /usr/lib/swift/linux/libdispatch.so

(lldb) target create "/usr/lib/swift/linux/libdispatch.so"
Current executable set to '/usr/lib/swift/linux/libdispatch.so' (x86_64).
(lldb) dis -n _dispatch_sema4_wait
libdispatch.so`_dispatch_sema4_wait:
libdispatch.so[0x3c580] <+0>:  pushq  %rbx
libdispatch.so[0x3c581] <+1>:  movq   %rdi, %rbx
libdispatch.so[0x3c584] <+4>:  nopw   %cs:(%rax,%rax)
libdispatch.so[0x3c590] <+16>: movq   %rbx, %rdi
libdispatch.so[0x3c593] <+19>: callq  0x1f410        ; symbol stub for: sem_wait
libdispatch.so[0x3c598] <+24>: cmpl   $-0x1, %eax
libdispatch.so[0x3c59b] <+27>: jne    0x3c5ac        ; <+44>
libdispatch.so[0x3c59d] <+29>: callq  0x1ee20        ; symbol stub for: __errno_location
libdispatch.so[0x3c5a2] <+34>: cmpl   $0x4, (%rax)
libdispatch.so[0x3c5a5] <+37>: je     0x3c590        ; <+16>
libdispatch.so[0x3c5a7] <+39>: callq  0x22c70        ; _dispatch_sema4_wait.cold.1
libdispatch.so[0x3c5ac] <+44>: popq   %rbx
libdispatch.so[0x3c5ad] <+45>: retq   

Same for the Swift overlay :(

No rbp pushing

(lldb) dis -n 'Dispatch.DispatchSemaphore.wait'
libswiftDispatch.so`wait:
libswiftDispatch.so[0x19120] <+0>: jmp    0x190b0        ; Dispatch.DispatchSemaphore.wait(wallTimeout: Dispatch.DispatchWallTime) -> Dispatch.DispatchTimeoutResult

libswiftDispatch.so`wait:
libswiftDispatch.so[0x190b0] <+0>:  pushq  %rax
libswiftDispatch.so[0x190b1] <+1>:  movq   %rdi, %rsi
libswiftDispatch.so[0x190b4] <+4>:  movq   0x10(%r13), %rdi
libswiftDispatch.so[0x190b8] <+8>:  callq  0x14ca0        ; symbol stub for: dispatch_semaphore_wait
libswiftDispatch.so[0x190bd] <+13>: testq  %rax, %rax
libswiftDispatch.so[0x190c0] <+16>: setne  %al
libswiftDispatch.so[0x190c3] <+19>: popq   %rcx
libswiftDispatch.so[0x190c4] <+20>: retq   

libswiftDispatch.so`wait:
libswiftDispatch.so[0x190a0] <+0>:  movq   0x10(%r13), %rdi
libswiftDispatch.so[0x190a4] <+4>:  movq   $-0x1, %rsi
libswiftDispatch.so[0x190ab] <+11>: jmp    0x14ca0        ; symbol stub for: dispatch_semaphore_wait

running the one-line repro:

$ docker run -it --rm --platform linux/amd64 swift:6.2-noble lldb --batch -o 'dis -n _dispatch_sema4_wait' /usr/lib/swift/linux/libdispatch.so
lldb[1]: ==== LLDB swift-healthcheck log. ===
This file contains the configuration of LLDB's embedded Swift compiler to help diagnosing module import and search path issues. The swift-healthcheck command is meant to be run *after* an error has occurred.
lldb version 17.0.0 (https://github.com/swiftlang/llvm-project.git revision f403f1080b28ed3bf592ccbc491dadda2a5d4814)
Swift version 6.2 (swift-6.2-RELEASE)

(lldb) target create "/usr/lib/swift/linux/libdispatch.so"
Current executable set to '/usr/lib/swift/linux/libdispatch.so' (x86_64).
(lldb) dis -n _dispatch_sema4_wait
libdispatch.so`_dispatch_sema4_wait:
libdispatch.so[0x3c580] <+0>:  pushq  %rbx
libdispatch.so[0x3c581] <+1>:  movq   %rdi, %rbx
libdispatch.so[0x3c584] <+4>:  nopw   %cs:(%rax,%rax)
libdispatch.so[0x3c590] <+16>: movq   %rbx, %rdi
libdispatch.so[0x3c593] <+19>: callq  0x1f410        ; symbol stub for: sem_wait
libdispatch.so[0x3c598] <+24>: cmpl   $-0x1, %eax
libdispatch.so[0x3c59b] <+27>: jne    0x3c5ac        ; <+44>
libdispatch.so[0x3c59d] <+29>: callq  0x1ee20        ; symbol stub for: __errno_location
libdispatch.so[0x3c5a2] <+34>: cmpl   $0x4, (%rax)
libdispatch.so[0x3c5a5] <+37>: je     0x3c590        ; <+16>
libdispatch.so[0x3c5a7] <+39>: callq  0x22c70        ; _dispatch_sema4_wait.cold.1
libdispatch.so[0x3c5ac] <+44>: popq   %rbx
libdispatch.so[0x3c5ad] <+45>: retq   

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

No source file or build entry point is identified. Start by running the provided Swift 6.2 Ubuntu 24.04 Docker and LLDB reproduction, then trace how libdispatch and the Swift overlay are compiled for Linux x86_64; done means the frame-pointer behavior and its build setting are explained and verified across the affected artifacts.

Written by the indexing model from the issue text.

Assessment

Tech stack
c, docker, linux, swift
Domain
build-system
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.