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

Can't compile under Linux #2147

Closed
2 tasks done
felix91gr opened this issue Apr 5, 2018 · 5 comments
Closed
2 tasks done

Can't compile under Linux #2147

felix91gr opened this issue Apr 5, 2018 · 5 comments

Comments

@felix91gr
Copy link

New Issue Checklist

Bug Report

SwiftLint does not compile under Linux using Swift 4.1

Complete output when running SwiftLint, including the stack trace and command used

N/A

Environment

  • SwiftLint version: master branch

  • Installation method used: swift build

  • Paste your configuration file: N/A

  • Are you using nested configurations?
    N/A

  • Which Xcode version are you using? N/A

  • Do you have a sample that shows the issue? N/A

@felix91gr
Copy link
Author

Compiling errors

The command I was using to compile was swift build -Xswiftc -suppress-warnings because otherwise the amount of warnings given by deprecations of 4.1 such as flatMap ~> compactMap was overwhelming.

Directly from master

felix@felix-X550LD ~/D/P/A/swiftLint> swift build -Xswiftc -suppress-warnings
/home/felix/Documents/Programming/AwesomeSystemSwift/swiftLint/Source/SwiftLintFramework/Extensions/Configuration+Merging.swift:58:27: error: cannot assign value of type 'ObjCBool' to type 'Bool'
            isDirectory = isDirectoryObjC
                          ^~~~~~~~~~~~~~~
error: terminated(1): /home/felix/Documents/Programming/Binaries/swift/swift-4.1-snapshot/usr/bin/swift-build-tool -f /home/felix/Documents/Programming/AwesomeSystemSwift/swiftLint/.build/debug.yaml main output:

Then I opened up Sublime and edited that error away like this:

These were the original lines:

let isDirectory: Bool
#if os(Linux)
    isDirectory = isDirectoryObjC
#else
    isDirectory = isDirectoryObjC.boolValue
#endif

And I changed them to:

let isDirectory: Bool
// #if os(Linux)
    // isDirectory = isDirectoryObjC
// #else
    isDirectory = isDirectoryObjC.boolValue
// #endif

After the first edit

felix@felix-X550LD ~/D/P/A/swiftLint> swift build -Xswiftc -suppress-warnings
Compile Swift Module 'SwiftLintFramework' (227 sources)
/home/felix/Documents/Programming/AwesomeSystemSwift/swiftLint/Source/SwiftLintFramework/Extensions/String+SwiftLint.swift:90:25: error: cannot convert value of type 'ObjCBool' to expected argument type 'Bool'
                return !isDirectoryObjC
                        ^~~~~~~~~~~~~~~
/home/felix/Documents/Programming/AwesomeSystemSwift/swiftLint/Source/SwiftLintFramework/Models/Configuration.swift:268:24: error: cannot convert return expression of type 'ObjCBool' to return type 'Bool'
                return isDir
                       ^~~~~
error: terminated(1): /home/felix/Documents/Programming/Binaries/swift/swift-4.1-snapshot/usr/bin/swift-build-tool -f /home/felix/Documents/Programming/AwesomeSystemSwift/swiftLint/.build/debug.yaml main output:

After I saw this I went ahead and made the same changes I made for the first error (the three are exactly the same #if os(Linux) setup). After those changes, the project compiled.

After it compiled

After it compiled I ran swift test and the program crashed:

Fatal error: Loading libsourcekitdInProc.so failed: file /home/felix/Documents/Programming/AwesomeSystemSwift/swiftLint/.build/checkouts/SourceKitten.git--8749486111266181366/Source/SourceKittenFramework/library_wrapper.swift, line 61
Current stack trace:
0    libswiftCore.so                    0x00007fdd1b9ae220 _swift_stdlib_reportFatalErrorInFile + 221
1    libswiftCore.so                    0x00007fdd1b71d33c <unavailable> + 1368892
2    libswiftCore.so                    0x00007fdd1b956f12 <unavailable> + 3702546
3    libswiftCore.so                    0x00007fdd1b958379 <unavailable> + 3707769
4    libswiftCore.so                    0x00007fdd1b71ca36 <unavailable> + 1366582
5    libswiftCore.so                    0x00007fdd1b956cdb <unavailable> + 3701979
6    libswiftCore.so                    0x00007fdd1b71ca36 <unavailable> + 1366582
7    libswiftCore.so                    0x00007fdd1b889e69 <unavailable> + 2862697
8    libswiftCore.so                    0x00007fdd1b71c350 _assertionFailure(_:_:file:line:flags:) + 44
9    SwiftLintPackageTests.xctest       0x000055c03c641a30 <unavailable> + 825904
10   SwiftLintPackageTests.xctest       0x000055c03c63af21 <unavailable> + 798497
11   libpthread.so.0                    0x00007fdd1a8a3a99 <unavailable> + 60057
12   libswiftCore.so                    0x00007fdd1b978dd0 swift_once + 95
13   SwiftLintPackageTests.xctest       0x000055c03c63af67 <unavailable> + 798567
14   SwiftLintPackageTests.xctest       0x000055c03c63af7d <unavailable> + 798589
15   libpthread.so.0                    0x00007fdd1a8a3a99 <unavailable> + 60057
16   libswiftCore.so                    0x00007fdd1b978dd0 swift_once + 95
17   SwiftLintPackageTests.xctest       0x000055c03c63b027 <unavailable> + 798759
18   SwiftLintPackageTests.xctest       0x000055c03c64f129 <unavailable> + 880937
19   SwiftLintPackageTests.xctest       0x000055c03c64f119 <unavailable> + 880921
20   libpthread.so.0                    0x00007fdd1a8a3a99 <unavailable> + 60057
21   libswiftCore.so                    0x00007fdd1b978dd0 swift_once + 95
22   SwiftLintPackageTests.xctest       0x000055c03c64f147 <unavailable> + 880967
23   SwiftLintPackageTests.xctest       0x000055c03c64f16d <unavailable> + 881005
24   SwiftLintPackageTests.xctest       0x000055c03c64f159 <unavailable> + 880985
25   libpthread.so.0                    0x00007fdd1a8a3a99 <unavailable> + 60057
26   libswiftCore.so                    0x00007fdd1b978dd0 swift_once + 95
27   SwiftLintPackageTests.xctest       0x000055c03c64f5d7 <unavailable> + 882135
28   SwiftLintPackageTests.xctest       0x000055c03c65953f <unavailable> + 922943
29   SwiftLintPackageTests.xctest       0x000055c03c6a0cce <unavailable> + 1215694
30   SwiftLintPackageTests.xctest       0x000055c03c6a0fa0 <unavailable> + 1216416
31   SwiftLintPackageTests.xctest       0x000055c03c6a5f41 <unavailable> + 1236801
32   SwiftLintPackageTests.xctest       0x000055c03c6a279b <unavailable> + 1222555
33   SwiftLintPackageTests.xctest       0x000055c03c6a1141 <unavailable> + 1216833
34   SwiftLintPackageTests.xctest       0x000055c03c6a1490 <unavailable> + 1217680
35   SwiftLintPackageTests.xctest       0x000055c03c6a5af1 <unavailable> + 1235697
36   SwiftLintPackageTests.xctest       0x000055c03c6a279b <unavailable> + 1222555
37   SwiftLintPackageTests.xctest       0x000055c03c6a3b62 <unavailable> + 1227618
38   SwiftLintPackageTests.xctest       0x000055c03c70334e <unavailable> + 1618766
39   SwiftLintPackageTests.xctest       0x000055c03c702f69 <unavailable> + 1617769
40   libpthread.so.0                    0x00007fdd1a8a3a99 <unavailable> + 60057
41   libswiftCore.so                    0x00007fdd1b978dd0 swift_once + 95
42   SwiftLintPackageTests.xctest       0x000055c03c703c07 <unavailable> + 1620999
43   SwiftLintPackageTests.xctest       0x000055c03c6e5ecd <unavailable> + 1498829
44   SwiftLintPackageTests.xctest       0x000055c03c9a87f5 <unavailable> + 4392949
45   SwiftLintPackageTests.xctest       0x000055c03c9a8726 <unavailable> + 4392742
46   libXCTest.so                       0x00007fdd1bba4b21 <unavailable> + 187169
47   libXCTest.so                       0x00007fdd1bb8ad50 XCTMain(_:) + 2364
48   SwiftLintPackageTests.xctest       0x000055c03ca09837 <unavailable> + 4790327
49   libc.so.6                          0x00007fdd19843740 __libc_start_main + 240
50   SwiftLintPackageTests.xctest       0x000055c03c5f8869 <unavailable> + 526441

@marcelofabri
Copy link
Collaborator

marcelofabri commented Apr 5, 2018

Compiling SwiftLint with Swift 4.1 is not supported yet. You probably should look into #2038.

@SDGGiesbrecht
Copy link
Contributor

As for the compiler error,

cannot assign value of type 'ObjCBool' to type 'Bool'

ObjCBool used to be distinct on macOS, but just an alias for Bool on Linux. That is the reason for all those #if directives.

I suspect just refactoring the #if directives so everything is the same as macOS as you have done should have been sufficient.


@felix91gr,

The runtime problem is quite unrelated.

Fatal error: Loading libsourcekitdInProc.so failed

Unless it has already worked for you with Swift 4.0 (in which case, look at #2038 as @marcelofabri said), you are probably running into the general quirks of Linux. Try reading #732 starting at this comment to see if you can find the information you need to prop it up on your system.

@felix91gr
Copy link
Author

felix91gr commented Apr 6, 2018

The runtime problem is quite unrelated.

Fatal error: Loading libsourcekitdInProc.so failed
Unless it has already worked for you with Swift 4.0 (in which case, look at #2038 as @marcelofabri said), you are probably running into the general quirks of Linux. Try reading #732 starting at this comment to see if you can find the information you need to prop it up on your system.

Thanks!

I added my LINUX_SOURCEKIT_LIB_PATH to my shell environment and now I can actually run the tests :)
I forgot that I had to configure that, since the last time I ran something that needed SourceKit was in a different installation of my OS and back then, Norio Nomura helped me make it work (Norio, if you're reading this: thanks again man!).

Now that libsourcekitdInProc.so comes included in the Linux toolchain (which also was possible thanks to Nomura), things are much easier :)

Many tests pass, btw. The test suite crashes at some point in the middle of the RulesTests suite, but passes all other test suites (except for the IntegrationTests one). Congrats for making it work so well in a second platform already ^^

@felix91gr
Copy link
Author

Other update: #2038 wow, Nomura again ruling the Linux porting of things. Seems like he's already fixed most of what I posted here in that PR. I'm gonna wait on it, and if it doesn't work, I'll post a new issue. Thanks y'all!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants