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

[DOC] changelog is not clear about the LLVM version #1939

Closed
H-G-Hristov opened this issue Sep 20, 2023 · 16 comments
Closed

[DOC] changelog is not clear about the LLVM version #1939

H-G-Hristov opened this issue Sep 20, 2023 · 16 comments
Labels

Comments

@H-G-Hristov
Copy link

Description

Using C++23 with the NDK r26

target_compile_features(${CMAKE_PROJECT_NAME}
        PUBLIC
            cxx_std_20)

with latest CMake

    externalNativeBuild {
        cmake {
            path = file("src/main/cpp/CMakeLists.txt")
            version = "3.27.5"
        }
    }

Adding this line to the default sample create by Android studio fails with:

FAILURE: Build completed with 4 failures.

1: Task failed with an exception.
-----------
* What went wrong:
Execution failed for task ':app:buildCMakeDebug[arm64-v8a]'.
> com.android.ide.common.process.ProcessException: ninja: Entering directory `/Users/hristohristov/AndroidStudioProjects/MyApplication2/app/.cxx/Debug/3c5w5n6q/arm64-v8a'
  [1/2] Building CXX object CMakeFiles/myapplication.dir/native-lib.cpp.o
  FAILED: CMakeFiles/myapplication.dir/native-lib.cpp.o 
  /Users/hristohristov/Library/Android/sdk/ndk/26.0.10792818/toolchains/llvm/prebuilt/darwin-x86_64/bin/clang++ --target=aarch64-none-linux-android29 --sysroot=/Users/hristohristov/Library/Android/sdk/ndk/26.0.10792818/toolchains/llvm/prebuilt/darwin-x86_64/sysroot -Dmyapplication_EXPORTS  -g -DANDROID -fdata-sections -ffunction-sections -funwind-tables -fstack-protector-strong -no-canonical-prefixes -D_FORTIFY_SOURCE=2 -Wformat -Werror=format-security   -fno-limit-debug-info  -std=gnu++23 -fPIC -MD -MT CMakeFiles/myapplication.dir/native-lib.cpp.o -MF CMakeFiles/myapplication.dir/native-lib.cpp.o.d -o CMakeFiles/myapplication.dir/native-lib.cpp.o -c /Users/hristohristov/AndroidStudioProjects/MyApplication2/app/src/main/cpp/native-lib.cpp
  error: invalid value 'gnu++23' in '-std=gnu++23'
  note: use 'c++98' or 'c++03' for 'ISO C++ 1998 with amendments' standard
  note: use 'gnu++98' or 'gnu++03' for 'ISO C++ 1998 with amendments and GNU extensions' standard
  note: use 'c++11' for 'ISO C++ 2011 with amendments' standard
  note: use 'gnu++11' for 'ISO C++ 2011 with amendments and GNU extensions' standard
  note: use 'c++14' for 'ISO C++ 2014 with amendments' standard
  note: use 'gnu++14' for 'ISO C++ 2014 with amendments and GNU extensions' standard
  note: use 'c++17' for 'ISO C++ 2017 with amendments' standard
  note: use 'gnu++17' for 'ISO C++ 2017 with amendments and GNU extensions' standard
  note: use 'c++20' for 'ISO C++ 2020 DIS' standard
  note: use 'gnu++20' for 'ISO C++ 2020 DIS with GNU extensions' standard
  note: use 'c++2b' for 'Working draft for ISO C++ 2023 DIS' standard
  note: use 'gnu++2b' for 'Working draft for ISO C++ 2023 DIS with GNU extensions' standard
  ninja: build stopped: subcommand failed.
  
  C++ build system [build] failed while executing:
      /opt/homebrew/bin/ninja \
        -C \
        /Users/hristohristov/AndroidStudioProjects/MyApplication2/app/.cxx/Debug/3c5w5n6q/arm64-v8a \
        myapplication
    from /Users/hristohristov/AndroidStudioProjects/MyApplication2/app

It looks like the toolchain doesn't support the latest standards C++23, C++26.

@DanAlbert
Copy link
Member

The version of Clang in r26 doesn't have this because upstream LLVM didn't. r27 will have a newer compiler.

I'm closing this because the only work here for us is "update clang again", which is something we always do as part of every major version, and we don't bother with tracking bugs for that (I can guarantee that I will not remember to close this bug when it is fixed, so it's not going to be a useful source of data).

@DanAlbert DanAlbert closed this as not planned Won't fix, can't repro, duplicate, stale Sep 20, 2023
@Zingam
Copy link

Zingam commented Sep 24, 2023

According to r26 release notes: Updated LLVM to clang-r487747c, based on LLVM 17 development.

Clang 17 does have the C++23 switch. How come the bundled doesn't do it? AFAIK these switches were added several months ago.

image

I'd argue that this is a bug as I expect that CMake provides the correct switches.

@DanAlbert
Copy link
Member

based on LLVM 17 development.

It is not 17.0. It is a development snapshot of LLVM 17. See the AndroidVersion.txt file in the same directory as the Clang binary.

@enh-google
Copy link
Collaborator

i suspect that's going to confuse others too. did we have clearer wording in the past we can reuse? if not, should we be more explicit with something like "between LLVM 16 and 17"?

@DanAlbert
Copy link
Member

It's the wording we've always used: https://github.com/android/ndk/wiki/Changelog-r17. Prior to NDK r17 changelogs didn't mention the LLVM version at all. It was much more obvious what the text meant when LLVM was still on svn and that revision number meant something obvious.

I was working on improving the wording already, but I'm about a dozen "one five minute task"s deep right now, so I'll reopen this so I don't forget to do that when I inevitably don't get to it today.

@DanAlbert DanAlbert changed the title [FR] C++23 support [DOC] changelog is not clear about the LLVM version Sep 25, 2023
@DanAlbert DanAlbert reopened this Sep 25, 2023
@DanAlbert
Copy link
Member

DanAlbert commented Sep 25, 2023

@Zingam

This comment was marked as off-topic.

rooteduniverse1003 pushed a commit to rooteduniverse1003/Android-Platform-NDK that referenced this issue Nov 22, 2023
Bug: android/ndk#1939
Test: None
(cherry picked from commit 843ac1b)
(cherry picked from https://android-review.googlesource.com/q/commit:6dc9d000a28c149220c3c3dbe23605d1b1d0c94a)
Merged-In: I6c5e612678487ae3398ff7bf9aafa754494dd094
Change-Id: I6c5e612678487ae3398ff7bf9aafa754494dd094
@H-G-Hristov
Copy link
Author

H-G-Hristov commented Feb 23, 2024

@DanAlbert The release notes:
https://github.com/android/ndk/wiki/Changelog-r26#r26c
claim:

Updated LLVM to clang-r487747e. See AndroidVersion.txt and clang_source_info.md in the toolchain directory for version information.

And checking in the toolchain directory I see the version number: 17.0.2 Does this mean that the toolchain was updated to a proper final 17.0.2 release from upstream or is it still the pre-release snapshot 17.0.0.
Starting LLVM 18, now the release versions will start with xx.1 (e.g. 18.1).
So my point is: if 17.0.2 isn't the RTM version than the notes are still misleading.

@DanAlbert
Copy link
Member

And checking in the toolchain directory I see the version number: 17.0.2 Does this mean that the toolchain was updated to a proper final 17.0.2 release from upstream

No, and it never will be. We will always build our own binaries for supply chain protection reasons. They are not going to be a direct match to any upstream release in the near future because upstream releases rarely meet the quality bar required to build Android.

So my point is: if 17.0.2 isn't the RTM version than the notes are still misleading.

That version isn't mentioned in the release notes.

@enh-google
Copy link
Collaborator

[17.0.2] isn't mentioned in the release notes.

not directly, but the release notes now point you here, which does say 17.0.2:

~/aosp-main-with-phones/prebuilts/clang/host/linux-x86/clang-r487747c$ cat AndroidVersion.txt 
17.0.2
based on r487747c
for additional information on LLVM revision and cherry-picks, see clang_source_info.md

@DanAlbert
Copy link
Member

Ah. That's up to @pirama-arumuga-nainar

@DanAlbert
Copy link
Member

@H-G-Hristov what questions are you actually trying to answer by finding the version number? The problem is that there is no version number to find other than the one in the changelog. "What is in this LLVM?" is answered by clang_source_info.md. If you're looking for a more succinct answer than that file, that's what r487747c is. If you're looking for a connection to an LLVM released version, there isn't one.

@pirama-arumuga-nainar
Copy link
Collaborator

[17.0.2] isn't mentioned in the release notes.

not directly, but the release notes now point you here

We should remove the mention of AndroidVersion.txt. clang_source_info.md is precise in describing what's in the toolchain (and doesn't mention any version numbers).

@DanAlbert
Copy link
Member

@pirama-arumuga-nainar
Copy link
Collaborator

Starting LLVM 18, now the release versions will start with xx.1 (e.g. 18.1).

This will also help going forward. Official LLVM releases will have a version of xx.1 while NDK/AOSP toolchains will have xx.0.y

@Zingam
Copy link

Zingam commented Apr 23, 2024

This is a bit off-topic.

I implemented several libc++ papers in LLVM 18 but none of them were included in NDK r27 currently. When does branching LLVM happen in AOSP?
If I want to get something into NDK r28 what would be the approximate deadline?

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

5 participants