Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SR-82] Undefined reference errors when linking against Foundation on Linux #5335

Closed
sharplet opened this issue Dec 6, 2015 · 4 comments
Closed
Labels

Comments

@sharplet
Copy link

sharplet commented Dec 6, 2015

Previous ID SR-82
Radar None
Original Reporter @sharplet
Type Bug
Status Resolved
Resolution Cannot Reproduce
Environment
$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 15.10
Release:    15.10
Codename:   wily
Additional Detail from JIRA
Votes 0
Component/s Package Manager
Labels Bug
Assignee None
Priority Medium

md5: 2175b88b9bbb7d223d9d9c8498681739

Issue Description:

I'm trying to get an existing project building on Linux.

The project is a wrapper around NSRegularExpression. I'm aware that NSRegularExpression is currently unimplemented on Linux. So I expected the code to compile and link successfully, but to see a runtime error.

Instead, the library compiles fine, but fails when linking to an executable with a number of undefined reference errors:

$ swift build
Compiling Swift Module 'Regex' (3 sources)
Linking Library:  .build/debug/Regex.a
Compiling Swift Module 'testregex' (1 sources)
Linking Executable:  .build/debug/testregex
/home/sharplet/src/scratch/testregex/.build/debug/Regex.a(MatchResult.swift.o): In function `_TFC5RegexP33_39987651F4A52C01A04E0211B81F3A7A12_MatchResultD':
/home/sharplet/src/scratch/testregex/.build/debug/Regex.o/Source/MatchResult.swift.o:(.text+0x10c1): undefined reference to `_TMaC10Foundation20NSTextCheckingResult'
/home/sharplet/src/scratch/testregex/.build/debug/Regex.a(MatchResult.swift.o): In function `_TFFC5RegexP33_39987651F4A52C01A04E0211B81F3A7A12_MatchResultg13captureRangesGSaGVs5RangeVVSS9UTF16View5Index__U_FT_GSaGS1_S3___':
/home/sharplet/src/scratch/testregex/Packages/Regex-0.2.3/Source/MatchResult.swift:43: undefined reference to `_TMV10Foundation8_NSRange'
/home/sharplet/src/scratch/testregex/Packages/Regex-0.2.3/Source/MatchResult.swift:43: undefined reference to `_TMV10Foundation8_NSRange'
/home/sharplet/src/scratch/testregex/.build/debug/Regex.a(MatchResult.swift.o): In function `_TMaGSaV10Foundation8_NSRange_':
/home/sharplet/src/scratch/testregex/Packages/Regex-0.2.3/Source/MatchResult.swift:(.text+0x20b3): undefined reference to `_TMV10Foundation8_NSRange'
/home/sharplet/src/scratch/testregex/.build/debug/Regex.a(MatchResult.swift.o): In function `_TMaGVs17IndexingGeneratorGSaV10Foundation8_NSRange__':
/home/sharplet/src/scratch/testregex/Packages/Regex-0.2.3/Source/MatchResult.swift:(.text+0x2128): undefined reference to `_TMV10Foundation8_NSRange'
/home/sharplet/src/scratch/testregex/.build/debug/Regex.a(MatchResult.swift.o): In function `_TMaGVs10ArraySliceV10Foundation8_NSRange_':
/home/sharplet/src/scratch/testregex/Packages/Regex-0.2.3/Source/MatchResult.swift:(.text+0x21a3): undefined reference to `_TMV10Foundation8_NSRange'
/home/sharplet/src/scratch/testregex/.build/debug/Regex.a(MatchResult.swift.o):/home/sharplet/src/scratch/testregex/Packages/Regex-0.2.3/Source/MatchResult.swift:(.text+0x22c8): more undefined references to `_TMV10Foundation8_NSRange' follow
...

When I import Foundation in the REPL and try to use NSRegularExpression, I see the expected runtime error.

Steps to reproduce:

1. Create a new directory with the following `Package.swift` file:

import PackageDescription

let package = Package(
  name: "testregex",
  dependencies: [
    .Package(url: "https://github.com/sharplet/Regex.git", majorVersion: 0, minor: 2),
  ]
)

2. Run swift build

@onevcat
Copy link
Contributor

onevcat commented Dec 17, 2015

@aciidgh
Copy link
Member

aciidgh commented Dec 19, 2015

it will work if you `import Foundation` in your executable

@mxcl
Copy link
Contributor

mxcl commented Dec 24, 2015

Works for me with the Dec-22nd snapshot.

@mxcl
Copy link
Contributor

mxcl commented Dec 24, 2015

   git clone https://github.com/sharplet/Regex && cd Regex && swift build

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
@shahmishal shahmishal transferred this issue from apple/swift May 4, 2022
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants