Skip to content

Legacy C++ driver treats static libraries as source files with WMO enabled #64454

@stevapple

Description

@stevapple

Description
swiftc (with legacy driver) unexpectedly treats static libraries as source files with -wmo flag, so it emits error diagnostics.

Steps to reproduce

// Module.swift
public func hello() {}

// main.swift
import Module
hello()

Windows:

  1. Run swiftc -emit-module -emit-library Module.swift;
  2. Run swiftc -disallow-use-new-driver -wmo -I. main.swift Module.lib.

Unix:

  1. Run swiftc -emit-module -emit-library -static Module.swift;
  2. Run swiftc -disallow-use-new-driver -wmo -I. main.swift libModule.a.

Expected behavior
This should run successfully with or without -wmo.

Environment
Swift version 5.9-dev (LLVM 230b7b8312a62d8, Swift 5ca8989242af5af)

Additional context
This is found when building swift-corelibs-libdispatch on Windows with CMake 3.26.0, which enables WMO for release build by default.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugA deviation from expected or documented behavior. Also: expected but undesirable behavior.legacy driverArea → compiler: the integrated C++ legacy driver. Succeeded by the swift-driver project

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions