Git Product home page Git Product logo

kotlin-symlinked-build's Introduction

Friend paths are not supported with a symlinked build directory

This is a repro for an issue where the Kotlin compiler fails to set up friend paths correctly if the build directory uses a symbolic link.

The following repro creates a second build directory build2 and then creates build as a symbolic link to build2 before running the compilation:

$ ./gradlew :test

The build fails with:

e: /Users/cpuerta/temp/KT-35341_symlink_test/src/test/kotlin/com/twitter/test/MyTest.kt: (8, 17): Cannot access 'MyClass': it is internal in 'com.twitter.test'

Running the following shows the compiler command-line:

$ ./gradlew :test -d | grep \\-Xfriend-paths
2020-06-13T14:28:44.688-0700 [DEBUG] [org.gradle.api.Task] [KOTLIN] :compileTestKotlin Kotlin compiler args: -Xallow-no-source-files -classpath /Users/cpuerta/temp/KT-35341_symlink_test/build/classes/kotlin/main:/Users/cpuerta/.gradle/caches/modules-2/files-2.1/junit/junit/4.12/2973d150c0dc1fefe998f834810d68f278ea58ec/junit-4.12.jar:/Users/cpuerta/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-stdlib/1.3.72/8032138f12c0180bc4e51fe139d4c52b46db6109/kotlin-stdlib-1.3.72.jar:/Users/cpuerta/.gradle/caches/modules-2/files-2.1/org.hamcrest/hamcrest-core/1.3/42a25dc3219429f0e5d060061f71acb49bf010a0/hamcrest-core-1.3.jar:/Users/cpuerta/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-stdlib-common/1.3.72/6ca8bee3d88957eaaaef077c41c908c9940492d8/kotlin-stdlib-common-1.3.72.jar:/Users/cpuerta/.gradle/caches/modules-2/files-2.1/org.jetbrains/annotations/13.0/919f0dfe192fb4e063e7dacadee7f8bb9a2672a9/annotations-13.0.jar -d /Users/cpuerta/temp/KT-35341_symlink_test/build/classes/kotlin/test -Xfriend-paths=/Users/cpuerta/temp/KT-35341_symlink_test/build2/classes/java/main,/Users/cpuerta/temp/KT-35341_symlink_test/build2/classes/kotlin/main -module-name kotlin-symlinked-build -no-reflect -no-stdlib -Xplugin=/Users/cpuerta/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-script-runtime/1.3.72/657d8d34d91e1964b4439378c09933e840bfe8d5/kotlin-script-runtime-1.3.72.jar,/Users/cpuerta/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-scripting-common/1.3.72/e09990437040879d692655d66f58a64318681ffe/kotlin-scripting-common-1.3.72.jar,/Users/cpuerta/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-scripting-compiler-embeddable/1.3.72/f8fb26323755b46c221da2b37a65da20381bc896/kotlin-scripting-compiler-embeddable-1.3.72.jar,/Users/cpuerta/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-scripting-compiler-impl-embeddable/1.3.72/fe188748283b313eb2ef17029bcdc4b861dfb53d/kotlin-scripting-compiler-impl-embeddable-1.3.72.jar,/Users/cpuerta/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-scripting-jvm/1.3.72/7dde2c909e6f1b80245c7ca100d32a8646b5666d/kotlin-scripting-jvm-1.3.72.jar,/Users/cpuerta/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-stdlib-common/1.3.72/6ca8bee3d88957eaaaef077c41c908c9940492d8/kotlin-stdlib-common-1.3.72.jar,/Users/cpuerta/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-stdlib/1.3.72/8032138f12c0180bc4e51fe139d4c52b46db6109/kotlin-stdlib-1.3.72.jar,/Users/cpuerta/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlinx/kotlinx-coroutines-core/1.2.1/3839faf625f4197acaeceeb6da000f011a2acb49/kotlinx-coroutines-core-1.2.1.jar,/Users/cpuerta/.gradle/caches/modules-2/files-2.1/org.jetbrains/annotations/13.0/919f0dfe192fb4e063e7dacadee7f8bb9a2672a9/annotations-13.0.jar -verbose /Users/cpuerta/temp/KT-35341_symlink_test/src/test/kotlin/com/twitter/test/MyTest.kt

The following command-line arguments explain the mismatch, since the friend paths use the canonical path, but the classpath does not:

-classpath /Users/cpuerta/temp/KT-35341_symlink_test/build/classes/kotlin/main:...
-Xfriend-paths=/Users/cpuerta/temp/KT-35341_symlink_test/build2/classes/java/main,/Users/cpuerta/temp/KT-35341_symlink_test/build2/classes/kotlin/main

The bug was likely introduced by this change.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.