From 524749a4e244b8dce73e6ce4741835e1dfd88520 Mon Sep 17 00:00:00 2001 From: Misha Chornyi <99709299+mc-nv@users.noreply.github.com> Date: Thu, 10 Sep 2026 20:15:25 -0700 Subject: [PATCH] build: Update C++ standard from c++17 to c++20 (#128) * build: Update C++ standard from c++17 to c++20 Upstream PyTorch raised ATen's minimum required C++ standard from 17 to 20 (pytorch/pytorch#178150), which broke the pytorch_backend build. Align this repo's TRITON_MIN_CXX_STANDARD/CMAKE_CXX_STANDARD default with that floor for consistency across the stack. TRI-1877 * fix: rename semaphore.h to avoid colliding with POSIX Under C++20, libstdc++'s transitively needs the POSIX to support std::counting_semaphore. This repo's own src/semaphore.h has the same name and sits ahead of the system include path (-I precedes default system dirs), so the compiler resolved the internal #include to this project's own header instead of glibc's, which defines no POSIX semaphore symbols. That broke the C++17->20 bump build with a cascade of "sem_t does not name a type" / "condition_variable does not name a type" errors. Rename to triton_semaphore.h so it can no longer shadow the system header; harmless under C++17 since nothing pulled in there. TRI-1877 * fix: rename filesystem.h/.cc to avoid colliding with Same class of bug as the semaphore.h rename in this repo: a project header sharing a name with a C++ standard library header, combined with -I preceding the system include path, means any future internal #include from libstdc++ (or a toolchain bump) would silently resolve to this project's own header instead. Not currently triggering a build failure, but proactively renamed given this repo already proved the pattern is live once. TRI-1877 (cherry picked from commit 38b69d018702d482608dae46c9775ab27f2007e1) --- CMakeLists.txt | 10 +++++----- src/instance_state.h | 2 +- src/model_state.h | 2 +- src/shared_library.cc | 4 ++-- src/{filesystem.cc => triton_filesystem.cc} | 2 +- src/{filesystem.h => triton_filesystem.h} | 2 +- src/{semaphore.h => triton_semaphore.h} | 2 +- 7 files changed, 12 insertions(+), 12 deletions(-) rename src/{filesystem.cc => triton_filesystem.cc} (97%) rename src/{filesystem.h => triton_filesystem.h} (96%) rename src/{semaphore.h => triton_semaphore.h} (96%) diff --git a/CMakeLists.txt b/CMakeLists.txt index 05def0b..58b9aa9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -28,8 +28,8 @@ cmake_minimum_required(VERSION 3.31.8) project(tritontensorrtbackend LANGUAGES C CXX) -# Use C++17 standard as Triton's minimum required. -set(TRITON_MIN_CXX_STANDARD 17 CACHE STRING "The minimum C++ standard which features are requested to build this target.") +# Use C++20 standard as Triton's minimum required. +set(TRITON_MIN_CXX_STANDARD 20 CACHE STRING "The minimum C++ standard which features are requested to build this target.") # # Options @@ -131,9 +131,9 @@ add_library( src/shape_tensor.h src/tensorrt_utils.cc src/tensorrt_utils.h - src/filesystem.h - src/filesystem.cc - src/semaphore.h + src/triton_filesystem.h + src/triton_filesystem.cc + src/triton_semaphore.h src/shared_library.h src/shared_library.cc src/loader.cc diff --git a/src/instance_state.h b/src/instance_state.h index 7e50c75..63ae4ee 100644 --- a/src/instance_state.h +++ b/src/instance_state.h @@ -34,11 +34,11 @@ #include "io_binding_info.h" #include "model_state.h" -#include "semaphore.h" #include "shape_tensor.h" #include "tensorrt_model_instance.h" #include "triton/backend/backend_input_collector.h" #include "triton/backend/backend_output_responder.h" +#include "triton_semaphore.h" namespace triton { namespace backend { namespace tensorrt { diff --git a/src/model_state.h b/src/model_state.h index 243edc8..bdf2b31 100644 --- a/src/model_state.h +++ b/src/model_state.h @@ -29,9 +29,9 @@ #include #include "logging.h" -#include "semaphore.h" #include "tensorrt_model.h" #include "tensorrt_model_instance.h" +#include "triton_semaphore.h" namespace triton { namespace backend { namespace tensorrt { diff --git a/src/shared_library.cc b/src/shared_library.cc index d4c762c..5faa656 100644 --- a/src/shared_library.cc +++ b/src/shared_library.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2022, NVIDIA CORPORATION. All rights reserved. +// Copyright (c) 2022-2026, NVIDIA CORPORATION. All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions @@ -26,9 +26,9 @@ #include "shared_library.h" -#include "filesystem.h" #include "logging.h" #include "mutex" +#include "triton_filesystem.h" /// FIXME: Duplication of core/src/shared_library.cc /// Separate shared_library to common library and delete this diff --git a/src/filesystem.cc b/src/triton_filesystem.cc similarity index 97% rename from src/filesystem.cc rename to src/triton_filesystem.cc index 4eb22ab..565bfbf 100644 --- a/src/filesystem.cc +++ b/src/triton_filesystem.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2022, NVIDIA CORPORATION. All rights reserved. +// Copyright (c) 2022-2026, NVIDIA CORPORATION. All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions diff --git a/src/filesystem.h b/src/triton_filesystem.h similarity index 96% rename from src/filesystem.h rename to src/triton_filesystem.h index 678a4b4..5f97127 100644 --- a/src/filesystem.h +++ b/src/triton_filesystem.h @@ -1,4 +1,4 @@ -// Copyright (c) 2022, NVIDIA CORPORATION. All rights reserved. +// Copyright (c) 2022-2026, NVIDIA CORPORATION. All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions diff --git a/src/semaphore.h b/src/triton_semaphore.h similarity index 96% rename from src/semaphore.h rename to src/triton_semaphore.h index 89c99b9..c50d696 100644 --- a/src/semaphore.h +++ b/src/triton_semaphore.h @@ -1,4 +1,4 @@ -// Copyright 2021, NVIDIA CORPORATION & AFFILIATES. All rights reserved. +// Copyright 2021-2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions