Skip to content

build: Go 1.26 C libraries miss runtime hooks on Darwin and Linux #2096

Description

@cpunion

Problem

On Darwin with Go 1.26, a C library whose exported Go function uses fmt cannot be linked. After the generic c-shared PIC/runtime-library blockers found while extending #2083 are removed, ld64.lld reports missing Go 1.26 runtime hooks from internal/synctest and Darwin CPU initialization.

This is separate from the funcinfo relocation/C ABI work in #2083: a runtime-only export using runtime.Callers and a goroutine can build, link, load, and execute, while adding fmt.Sprintf pulls in the missing hooks below.

Reproducer

package main

import "fmt"

//export Format
func Format(value string, number int) string {
	return fmt.Sprintf("%s:%d", value, number)
}

func main() {}
llgo build -buildmode=c-shared -o export .

Environment used:

  • xgo-dev/llgo main 2c9d1897dbfaabe78c08e56a2ff77f0f6b2bbcca
  • Go 1.26.5
  • LLVM/Clang 19.1.7
  • macOS arm64

Actual result

ld64.lld reports unresolved symbols including:

internal/synctest.acquire
internal/synctest.release
internal/synctest.inBubble
internal/cpu.sysctlbynameBytes
internal/cpu.sysctlbynameInt32

internal/synctest.Acquire itself is present, but its lowercase runtime hooks are not. The Darwin internal/cpu package likewise expects sysctl helpers that are not supplied to the external link.

Linux arm64 with Go 1.24.2 builds the equivalent fmt probe, but that does not exercise the new Go 1.26 internal/synctest dependency. This should be covered natively with Go 1.26 on both Darwin and Linux.

Expected result

Exported functions in c-shared and c-archive libraries can use supported standard-library packages such as fmt, and a C consumer can link and execute them.

Suggested coverage

Related: #2083, #2088

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions