Skip to content

[SR-14122] Improve usability of -l flag. #56503

@typesanitizer

Description

@typesanitizer
Previous ID SR-14122
Radar rdar://problem/73742492
Original Reporter @typesanitizer
Type Improvement
Status Closed
Resolution Done

Attachment: Download

Additional Detail from JIRA
Votes 0
Component/s Compiler
Labels Improvement, StarterBug
Assignee Rajagopalan (JIRA)
Priority Medium

md5: 5811a36dd197d1a76e8beeedde7c7974

Issue Description:

According to the swiftc help page, one can use -l<value> to ask it to link to a library. However, if one adds a space -l <value>, then swiftc emits a strange error error: no such file or directory: 'tmp1'.

We should be consistent with -L and allow a space between the flag and the argument. Alternately, if we want to be consistent with ld64, we can emit an error instead that we got an empty value for -l ("did you add an extra space after '-l'?").

Here's an example of when one could hit this error:

echo 'public func f() { print("Hello") }' > tmp1.swift
xcrun swiftc tmp1.swift -enable-library-evolution  -emit-module-interface-path tmp1.swiftinterface -emit-library -o libtmp1.dylib
echo 'import tmp1\n\ntmp1.f()' > tmp2.swift
xcrun swiftc tmp2.swift -I . -c -o tmp2.o
xcrun swiftc tmp2.o -L . -l tmp1

Fixing this to -ltmp1 would fix the issue (as you can check by running ./tmp2).

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions