Bug 244810

Summary: Mk/Uses/compiler.mk: Add compiler:c++20-lang
Product: Ports & Packages Reporter: Yuri Victorovich <yuri>
Component: Ports FrameworkAssignee: Port Management Team <portmgr>
Status: Closed FIXED    
Severity: Affects Some People CC: olevole, ports-bugs, zirias
Priority: --- Keywords: feature
Version: Latest   
Hardware: Any   
OS: Any   
Attachments:
Description Flags
Mk/Uses/compiler.mk: Add compiler:c++20-lang none

Description Yuri Victorovich freebsd_committer freebsd_triage 2020-03-14 18:34:42 UTC
There compiler:c++17-lang and compiler:c++17-lang, but no compiler:c++20-lang

Some C++ features were introduced in C++20, for example std::identity, see https://en.cppreference.com/w/cpp/utility/functional/identity
Comment 1 Oleg Ginzburg 2021-04-23 07:46:15 UTC
++, some ports (for example, latest version of clickhouse ) started using -std=c++20 code
Comment 2 Oleg Ginzburg 2021-04-23 08:41:38 UTC
I'm not sure that this is enough:

--
--- compiler.mk.orig    2021-04-09 12:39:56.641342000 +0300
+++ compiler.mk 2021-04-23 11:00:54.440261000 +0300
@@ -8,6 +8,7 @@
 # c++11-lang:  The port needs a compiler understanding C++11
 # c++14-lang:  The port needs a compiler understanding C++14
 # c++17-lang:  The port needs a compiler understanding C++17
+# c++20-lang:  The port needs a compiler understanding C++20
 # gcc-c++11-lib:The port needs g++ compiler with a C++11 library
 # c++11-lib:   The port needs a compiler understanding C++11 and with a C++11 ready standard library
 # c11:         The port needs a compiler understanding C11
@@ -34,7 +35,7 @@
 compiler_ARGS= env
 .endif
 
-VALID_ARGS=    c++11-lib c++11-lang c++14-lang c++17-lang c11 features openmp env nestedfct c++0x gcc-c++11-lib
+VALID_ARGS=    c++11-lib c++11-lang c++14-lang c++17-lang c++20-lang c11 features openmp env nestedfct c++0x gcc-c++11-lib
 
 _CC_hash:=     ${CC:hash}
 _CXX_hash:=    ${CXX:hash}
@@ -51,6 +52,8 @@
 _COMPILER_ARGS+=       features c++14-lang
 .elif ${compiler_ARGS} == c++17-lang
 _COMPILER_ARGS+=       features c++17-lang
+.elif ${compiler_ARGS} == c++20-lang
+_COMPILER_ARGS+=       features c++20-lang
 .elif ${compiler_ARGS} == c11
 _COMPILER_ARGS+=       features c11
 .elif ${compiler_ARGS} == features
@@ -139,7 +142,7 @@
 .endif
 
 CSTD=  c89 c99 c11 gnu89 gnu99 gnu11
-CXXSTD=        c++98 c++0x c++11 c++14 c++17 gnu++98 gnu++11 gnu++14 gnu++17
+CXXSTD=        c++98 c++0x c++11 c++14 c++17 c++20 gnu++98 gnu++11 gnu++14 gnu++17
 
 .for std in ${CSTD} ${CXXSTD}
 _LANG=c
@@ -169,7 +172,8 @@
 .endif
 .endif
 
-.if (${_COMPILER_ARGS:Mc++17-lang} && !${COMPILER_FEATURES:Mc++17}) || \
+.if (${_COMPILER_ARGS:Mc++20-lang} && !${COMPILER_FEATURES:Mc++20}) || \
+(${_COMPILER_ARGS:Mc++17-lang} && !${COMPILER_FEATURES:Mc++17}) || \
 (${_COMPILER_ARGS:Mc++14-lang} && !${COMPILER_FEATURES:Mc++14}) || \
 (${_COMPILER_ARGS:Mc++11-lang} && !${COMPILER_FEATURES:Mc++11}) || \
 (${_COMPILER_ARGS:Mc++0x} && !${COMPILER_FEATURES:Mc++0x}) || \
--


Perhaps we should additionally explicitly indicate the dependency on the llvm clang11 here, e.g.:
--
BUILD_DEPENDS+= ${LOCALBASE}/bin/clang11:devel/llvm11
CPP=    ${LOCALBASE}/bin/clang-cpp11
CC=     ${LOCALBASE}/bin/clang11
CXX=    ${LOCALBASE}/bin/clang++11
--
Comment 3 Kubilay Kocak freebsd_committer freebsd_triage 2021-04-23 09:06:12 UTC
(In reply to olevole from comment #2)

If you could provide any diffs as attachments instead of pasted as comments, that'd be great. Thank you!
Comment 4 Oleg Ginzburg 2021-04-23 10:04:25 UTC
Created attachment 224372 [details]
Mk/Uses/compiler.mk: Add compiler:c++20-lang
Comment 5 commit-hook freebsd_committer freebsd_triage 2022-09-11 11:36:31 UTC
A commit in branch main references this bug:

URL: https://cgit.FreeBSD.org/ports/commit/?id=5ca22080ae08a6707bbcb9af0529e9d54aa832d5

commit 5ca22080ae08a6707bbcb9af0529e9d54aa832d5
Author:     Felix Palmen <zirias@FreeBSD.org>
AuthorDate: 2022-08-25 08:36:02 +0000
Commit:     Felix Palmen <zirias@FreeBSD.org>
CommitDate: 2022-09-11 11:34:29 +0000

    Mk/Uses/compiler.mk: Support newer C++ standards

    * Add c++20-lang and c++2b-lang arguments
    * Respect LLVM_DEFAULT if it fullfills the requirements

    PR:                     244810, 266029
    Exp-run by:             antoine
    Approved by:            bapt, tcberner (mentor)
    Differential Revision:  https://reviews.freebsd.org/D35889

 Mk/Uses/compiler.mk | 42 +++++++++++++++++++++++++++++++++---------
 1 file changed, 33 insertions(+), 9 deletions(-)
Comment 6 Felix Palmen freebsd_committer freebsd_triage 2022-09-11 11:38:55 UTC
Fixed with this commit.