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-15532] Compiler doesn't load public property declarations in another module under some conditions. #57835

Open
YOCKOW opened this issue Nov 30, 2021 · 4 comments
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler in itself

Comments

@YOCKOW
Copy link
Collaborator

YOCKOW commented Nov 30, 2021

Previous ID SR-15532
Radar rdar://problem/88618173
Original Reporter @YOCKOW
Type Bug
Environment

[OS]

  • Ubuntu 20.04

[Swift]

  • Swift version 5.5.1 (swift-5.5.1-RELEASE)
    Target: x86_64-unknown-linux-gnu

  • Swift version 5.6-dev (LLVM 542eceb110d8480, Swift 4323d2f)
    Target: x86_64-unknown-linux-gnu

Additional Detail from JIRA
Votes 1
Component/s Compiler
Labels Bug
Assignee None
Priority Medium

md5: e271fa8e56c7610380594dd5d0974492

relates to:

  • SR-15462 Regression: Swift 5.5 on Linux doesn't see extension on timeval_t
  • SR-15586 import Foundation hides declarations (derived from C) in other modules on Linux.

Issue Description:

How to reproduce

Step 1: Prepare 2 files, "library.swift" and "user.swift" as following:

// library.swift
import Foundation
public typealias A = in_addr
extension A {
  public var foo: String { return "foo" }
}
// user.swift
import MyLib
let a = A()
print(a.foo)

Step 2: Compile "library.swift" as a library named "MyLib"

swiftc library.swift -emit-module -emit-library -module-name MyLib

Step 3: Compile "user.swift" and execute it.

swiftc user.swift -I. -L. -lMyLib && ./user

Results

macOS + Swift 5.5

"foo" is printed successfully.

Linux + Swift 5.5

Compilation fails like below:

user.swift:4:9: error: value of type 'A' (aka 'in_addr') has no member 'foo'
print(a.foo)
      ~ ^~~
@YOCKOW
Copy link
Collaborator Author

YOCKOW commented Dec 6, 2021

Symbols exist in the .so file:

$ nm libMyLib.so 
                 U $sSS21_builtinStringLiteral17utf8CodeUnitCount7isASCIISSBp_BwBi1_tcfC
00000000000009dc T $sSo7in_addrV5MyLibE3fooSSvg
0000000000000a2c R $sSo7in_addrV5MyLibE3fooSSvpMV
000000000001fd00 d _DYNAMIC
000000000001ffc0 d _GLOBAL_OFFSET_TABLE_
                 w _ITM_deregisterTMCloneTable
                 w _ITM_registerTMCloneTable
00000000000008bc t _ZL23swift_image_constructorv
0000000000020030 d _ZL4Note
0000000000020068 b _ZN12_GLOBAL__N_18sectionsE
0000000000000b20 r __FRAME_END__
0000000000020030 d __TMC_END__
0000000000020030 d __TMC_LIST__
000000000002005f D __bss_start
                 w __cxa_finalize
0000000000000870 t __do_global_dtors_aux
000000000001fce0 d __do_global_dtors_aux_fini_array_entry
0000000000020028 d __dso_handle
000000000001fce8 d __frame_dummy_init_array_entry
                 w __gmon_start__
0000000000000a28 r __start_swift5_assocty
0000000000000a28 r __start_swift5_builtin
0000000000000a28 r __start_swift5_capture
0000000000000a28 r __start_swift5_fieldmd
0000000000000a28 r __start_swift5_protocol_conformances
0000000000000a28 r __start_swift5_protocols
0000000000000a28 r __start_swift5_reflstr
0000000000000a28 r __start_swift5_replac2
0000000000000a28 r __start_swift5_replace
0000000000000a28 r __start_swift5_type_metadata
0000000000000a28 r __start_swift5_typeref
0000000000000a28 r __stop_swift5_assocty
0000000000000a28 r __stop_swift5_builtin
0000000000000a28 r __stop_swift5_capture
0000000000000a28 r __stop_swift5_fieldmd
0000000000000a28 r __stop_swift5_protocol_conformances
0000000000000a28 r __stop_swift5_protocols
0000000000000a28 r __stop_swift5_reflstr
0000000000000a28 r __stop_swift5_replac2
0000000000000a28 r __stop_swift5_replace
0000000000000a28 r __stop_swift5_type_metadata
0000000000000a28 r __stop_swift5_typeref
0000000000000a30 r __swift_reflection_version
000000000002005f D _edata
0000000000020138 D _end
0000000000000a18 t _fini
0000000000000760 t _init
                 w _swift_FORCE_LOAD_$_swiftGlibc
000000000001fcf8 d _swift_FORCE_LOAD_$_swiftGlibc_$_MyLib
00000000000007e8 t call_weak_fn
0000000000020060 b completed.9126
0000000000000800 t deregister_tm_clones
00000000000008b8 t frame_dummy
0000000000000830 t register_tm_clones
                 U swift_addNewDSOImage

.swiftinterface contains the public declaration. (Maybe .swiftmodule also does.)

// swift-interface-format-version: 1.0
// swift-compiler-version: Swift version 5.5.1 (swift-5.5.1-RELEASE)
// swift-module-flags: -target aarch64-unknown-linux-gnu -disable-objc-interop -enable-library-evolution -module-name MyLib
import Foundation
import Swift
import _Concurrency
public typealias A = SwiftGlibc.in_addr
extension SwiftGlibc.in_addr {
  public var foo: Swift.String {
    get
  }
}

Is ModuleLoader responsible for this issue?

@YOCKOW
Copy link
Collaborator Author

YOCKOW commented Dec 13, 2021

I suspect that SR-15586 causes this issue.

@weissi
Copy link
Member

weissi commented Feb 8, 2022

@swift-ci create

@weissi
Copy link
Member

weissi commented Feb 8, 2022

CC @jckarter this looks pretty bad, no?

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler in itself
Projects
None yet
Development

No branches or pull requests

2 participants