bump abseil to Jan 2024 release; remove vlog patch; simplify lpi_glop code; bump protobuf to 25.2

This commit is contained in:
Laurent Perron
2024-01-31 16:51:24 +01:00
parent 792b61cd42
commit 0ddf9d5978
12 changed files with 62 additions and 458 deletions

View File

@@ -1,5 +1,5 @@
Protobuf=v25.1
abseil-cpp=20230802.1
Protobuf=v25.2
abseil-cpp=20240116.0
Cbc=2.10.7
Cgl=0.60.5
Clp=1.17.7

View File

@@ -88,9 +88,7 @@ git_repository(
## Abseil-cpp
git_repository(
name = "com_google_absl",
tag = "20230802.1",
patches = ["//patches:abseil-cpp-20230802.1.patch"],
patch_args = ["-p1"],
tag = "20240116.0",
remote = "https://github.com/abseil/abseil-cpp.git",
)
@@ -100,9 +98,9 @@ git_repository(
# This statement defines the @com_google_protobuf repo.
git_repository(
name = "com_google_protobuf",
patches = ["//patches:protobuf-v25.1.patch"],
patches = ["//patches:protobuf-v25.2.patch"],
patch_args = ["-p1"],
tag = "v25.1",
tag = "v25.2",
remote = "https://github.com/protocolbuffers/protobuf.git",
)
# Load common dependencies.

View File

@@ -2,7 +2,31 @@ diff --git a/src/lpi/lpi_glop.cpp b/src/lpi/lpi_glop.cpp
index 2471778a8f..17fd1e8c34 100644
--- a/src/lpi/lpi_glop.cpp
+++ b/src/lpi/lpi_glop.cpp
@@ -3190,6 +3190,6 @@ SCIP_RETCODE SCIPlpiReadLP(
@@ -51,7 +51,6 @@
#include "ortools/util/time_limit.h"
#include "ortools/base/logging.h"
-#include "ortools/base/vlog_is_on.h"
#include "lpi/lpi.h"
#include "scip/pub_message.h"
@@ -2942,12 +2941,12 @@ SCIP_RETCODE SCIPlpiSetIntpar(
SCIPdebugMessage("SCIPlpiSetIntpar: SCIP_LPPAR_LPINFO -> %d.\n", ival);
if ( ival == 0 )
{
- (void) google::SetVLOGLevel("*", google::GLOG_INFO);
+ absl::SetFlag(&FLAGS_stderrthreshold, 2);
lpi->lp_info = false;
}
else
{
- (void) google::SetVLOGLevel("*", google::GLOG_ERROR);
+ absl::SetFlag(&FLAGS_stderrthreshold, 0);
lpi->lp_info = true;
}
break;
@@ -3190,7 +3189,7 @@ SCIP_RETCODE SCIPlpiReadLP(
const std::string filespec(fname);
MPModelProto proto;
- if ( ! ReadFileToProto(filespec, &proto) )
@@ -10,7 +34,7 @@ index 2471778a8f..17fd1e8c34 100644
{
SCIPerrorMessage("Could not read <%s>\n", fname);
return SCIP_READERROR;
@@ -3214,7 +3214,7 @@ SCIP_RETCODE SCIPlpiWriteLP(
@@ -3214,7 +3213,7 @@ SCIP_RETCODE SCIPlpiWriteLP(
MPModelProto proto;
LinearProgramToMPModelProto(*lpi->linear_program, &proto);
const std::string filespec(fname);

View File

@@ -82,8 +82,7 @@ if(BUILD_absl)
FetchContent_Declare(
abseil-cpp
GIT_REPOSITORY "https://github.com/abseil/abseil-cpp.git"
GIT_TAG "20230802.1"
PATCH_COMMAND git apply --ignore-whitespace "${CMAKE_CURRENT_LIST_DIR}/../../patches/abseil-cpp-20230802.1.patch"
GIT_TAG "20240116.0"
)
FetchContent_MakeAvailable(abseil-cpp)
list(POP_BACK CMAKE_MESSAGE_INDENT)
@@ -103,9 +102,9 @@ if(BUILD_Protobuf)
FetchContent_Declare(
Protobuf
GIT_REPOSITORY "https://github.com/protocolbuffers/protobuf.git"
GIT_TAG "v25.1"
GIT_TAG "v25.2"
GIT_SUBMODULES ""
PATCH_COMMAND git apply --ignore-whitespace "${CMAKE_CURRENT_LIST_DIR}/../../patches/protobuf-v25.1.patch")
PATCH_COMMAND git apply --ignore-whitespace "${CMAKE_CURRENT_LIST_DIR}/../../patches/protobuf-v25.2.patch")
FetchContent_MakeAvailable(Protobuf)
list(POP_BACK CMAKE_MESSAGE_INDENT)
message(CHECK_PASS "fetched")

View File

@@ -293,7 +293,6 @@ cc_library(
hdrs = ["logging.h"],
deps = [
":macros",
":vlog",
"@com_google_absl//absl/base:log_severity",
"@com_google_absl//absl/flags:flag",
"@com_google_absl//absl/flags:usage",
@@ -319,20 +318,6 @@ cc_library(
hdrs = ["types.h"],
)
cc_library(
name = "vlog",
srcs = ["vlog_is_on.cc"],
hdrs = [
"vlog.h",
"vlog_is_on.h",
],
deps = [
"@com_google_absl//absl/flags:flag",
"@com_google_absl//absl/log",
"@com_google_absl//absl/log:check",
],
)
cc_library(
name = "macros",
hdrs = ["macros.h"],

View File

@@ -14,12 +14,9 @@
#ifndef OR_TOOLS_BASE_LOGGING_H_
#define OR_TOOLS_BASE_LOGGING_H_
#define ABSL_LOG_INTERNAL_CONDITION_DFATAL ABSL_LOG_INTERNAL_CONDITION_ERROR
#define kLogDebugFatal LogSeverity::kError
#define kDebugFatal kError
#include "absl/base/log_severity.h"
#include "absl/flags/declare.h"
#include "absl/flags/flag.h"
#include "absl/log/check.h"
#include "absl/log/die_if_null.h"
#include "absl/log/log.h"
@@ -28,7 +25,6 @@
#include "absl/strings/str_cat.h"
#include "absl/strings/string_view.h"
#include "ortools/base/macros.h"
#include "ortools/base/vlog.h"
// Compatibility layer for glog/previous logging code.
ABSL_DECLARE_FLAG(bool, logtostderr);
@@ -42,14 +38,4 @@ void FixFlagsAndEnvironmentForSwig();
} // namespace operations_research
// Compatibility layer for SCIP
namespace google {
enum LogSeverity {
GLOG_INFO = static_cast<int>(absl::LogSeverity::kInfo),
GLOG_WARNING = static_cast<int>(absl::LogSeverity::kWarning),
GLOG_ERROR = static_cast<int>(absl::LogSeverity::kError),
GLOG_FATAL = static_cast<int>(absl::LogSeverity::kFatal),
};
} // namespace google
#endif // OR_TOOLS_BASE_LOGGING_H_

View File

@@ -1,52 +0,0 @@
// Copyright 2010-2024 Google LLC
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#ifndef OR_TOOLS_BASE_VLOG_H_
#define OR_TOOLS_BASE_VLOG_H_
#include <errno.h>
#include <string.h>
#include <time.h>
#include <cassert>
#include <cstddef>
#include <iosfwd>
#include <ostream>
#include <sstream>
#include <string>
#if defined(__GNUC__) && defined(__linux__)
#include <unistd.h>
#endif
#include <vector>
#include "absl/flags/flag.h"
#include "absl/log/check.h"
#include "ortools/base/vlog_is_on.h"
// Log only in verbose mode.
#define VLOG(verboselevel) LOG_IF(INFO, VLOG_IS_ON(verboselevel))
#define VLOG_EVERY_N(verboselevel, n) \
LOG_IF_EVERY_N(INFO, VLOG_IS_ON(verboselevel), n)
#define VLOG_EVERY_N_SEC(verboselevel, n) \
LOG_IF_EVERY_N_SEC(INFO, VLOG_IS_ON(verboselevel), n)
#if defined(DEBUG_MODE)
#define DVLOG(verboselevel) VLOG(verboselevel)
#else // !defined(DEBUG_MODE)
#define DVLOG(verboselevel) LOG_IF(INFO, false)
#endif // !defined(DEBUG_MODE)
#endif // OR_TOOLS_BASE_VLOG_H_

View File

@@ -1,227 +0,0 @@
// Copyright 2010-2024 Google LLC
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#include "ortools/base/vlog_is_on.h"
#include <errno.h>
#include <stdlib.h>
#include <cstdio>
#include <cstring>
#include <string>
#include "absl/flags/flag.h"
#include "absl/synchronization/mutex.h"
ABSL_FLAG(int, v, 0,
"Show all VLOG(m) messages for m <= this."
" Overridable by --vmodule.");
ABSL_FLAG(std::string, vmodule, "",
"per-module verbose level."
" Argument is a comma-separated list of <module name>=<log level>."
" <module name> is a glob pattern, matched against the filename base"
" (that is, name ignoring .cc/.h./-inl.h)."
" <log level> overrides any value given by --v.");
namespace google {
namespace logging_internal {
// Used by logging_unittests.cc so can't make it static here.
bool SafeFNMatch_(const char* pattern, size_t patt_len, const char* str,
size_t str_len);
// Implementation of fnmatch that does not need 0-termination
// of arguments and does not allocate any memory,
// but we only support "*" and "?" wildcards, not the "[...]" patterns.
// It's not a static function for the unittest.
bool SafeFNMatch_(const char* pattern, size_t patt_len, const char* str,
size_t str_len) {
size_t p = 0;
size_t s = 0;
while (1) {
if (p == patt_len && s == str_len) return true;
if (p == patt_len) return false;
if (s == str_len) return p + 1 == patt_len && pattern[p] == '*';
if (pattern[p] == str[s] || pattern[p] == '?') {
p += 1;
s += 1;
continue;
}
if (pattern[p] == '*') {
if (p + 1 == patt_len) return true;
do {
if (SafeFNMatch_(pattern + (p + 1), patt_len - (p + 1), str + s,
str_len - s)) {
return true;
}
s += 1;
} while (s != str_len);
return false;
}
return false;
}
}
} // namespace logging_internal
using logging_internal::SafeFNMatch_;
int32_t kLogSiteUninitialized = 1000;
// List of per-module log levels from absl::GetFlag(FLAGS_vmodule).
// Once created each element is never deleted/modified
// except for the vlog_level: other threads will read VModuleInfo blobs
// w/o locks and we'll store pointers to vlog_level at VLOG locations
// that will never go away.
// We can't use an STL struct here as we wouldn't know
// when it's safe to delete/update it: other threads need to use it w/o locks.
struct VModuleInfo {
std::string module_pattern;
mutable int32_t vlog_level; // Conceptually this is an AtomicWord, but it's
// too much work to use AtomicWord type here
// w/o much actual benefit.
const VModuleInfo* next;
};
// This protects the following global variables.
static absl::Mutex vmodule_lock;
// Pointer to head of the VModuleInfo list.
// It's a map from module pattern to logging level for those module(s).
static VModuleInfo* vmodule_list = 0;
// Boolean initialization flag.
static bool inited_vmodule = false;
// L >= vmodule_lock.
static void VLOG2Initializer() {
vmodule_lock.AssertHeld();
// Can now parse --vmodule flag and initialize mapping of module-specific
// logging levels.
inited_vmodule = false;
const std::string vmodule_flag = absl::GetFlag(FLAGS_vmodule);
const char* vmodule = vmodule_flag.c_str();
const char* sep;
VModuleInfo* head = nullptr;
VModuleInfo* tail = nullptr;
while ((sep = strchr(vmodule, '=')) != nullptr) {
std::string pattern(vmodule, sep - vmodule);
int module_level;
if (sscanf(sep, "=%d", &module_level) == 1) {
VModuleInfo* info = new VModuleInfo;
info->module_pattern = pattern;
info->vlog_level = module_level;
if (head)
tail->next = info;
else
head = info;
tail = info;
}
// Skip past this entry
vmodule = strchr(sep, ',');
if (vmodule == nullptr) break;
vmodule++; // Skip past ","
}
if (head) { // Put them into the list at the head:
tail->next = vmodule_list;
vmodule_list = head;
}
inited_vmodule = true;
}
// This can be called very early, so we use SpinLock and RAW_VLOG here.
int SetVLOGLevel(const char* module_pattern, int log_level) {
int result = absl::GetFlag(FLAGS_v);
int const pattern_len = strlen(module_pattern);
bool found = false;
{
absl::MutexLock l(&vmodule_lock); // protect whole read-modify-write
for (const VModuleInfo* info = vmodule_list; info != nullptr;
info = info->next) {
if (info->module_pattern == module_pattern) {
if (!found) {
result = info->vlog_level;
found = true;
}
info->vlog_level = log_level;
} else if (!found && SafeFNMatch_(info->module_pattern.c_str(),
info->module_pattern.size(),
module_pattern, pattern_len)) {
result = info->vlog_level;
found = true;
}
}
if (!found) {
VModuleInfo* info = new VModuleInfo;
info->module_pattern = module_pattern;
info->vlog_level = log_level;
info->next = vmodule_list;
vmodule_list = info;
}
}
// RAW_VLOG(1, "Set VLOG level for \"%s\" to %d", module_pattern, log_level);
return result;
}
// NOTE: Individual VLOG statements cache the integer log level pointers.
// NOTE: This function must not allocate memory or require any locks.
bool InitVLOG3__(int32_t** vmodule_info, bool* initialized, const char* fname,
int32_t verbose_level) {
absl::MutexLock l(&vmodule_lock);
bool read_vmodule_flag = inited_vmodule;
if (!read_vmodule_flag) {
VLOG2Initializer();
}
// protect the errno global in case someone writes:
// VLOG(..) << "The last error was " << strerror(errno)
int old_errno = errno;
// Set the initialized flag.
*initialized = true;
// Get basename for file
const char* base = strrchr(fname, '/');
base = base ? (base + 1) : fname;
const char* base_end = strchr(base, '.');
size_t base_length = base_end ? size_t(base_end - base) : strlen(base);
// Trim out trailing "-inl" if any
if (base_length >= 4 && (memcmp(base + base_length - 4, "-inl", 4) == 0)) {
base_length -= 4;
}
// TODO: Trim out _unittest suffix? Perhaps it is better to have
// the extra control and just leave it there.
// find target in vector of modules, replace site_flag_value with
// a module-specific verbose level, if any.
for (const VModuleInfo* info = vmodule_list; info != nullptr;
info = info->next) {
if (SafeFNMatch_(info->module_pattern.c_str(), info->module_pattern.size(),
base, base_length)) {
*vmodule_info = &info->vlog_level;
// value at info->vlog_level is now what controls
// the VLOG at the caller site forever
break;
}
}
// restore the errno in case something recoverable went wrong during
// the initialization of the VLOG mechanism (see above note "protect the..")
errno = old_errno;
return *vmodule_info == nullptr ? absl::GetFlag(FLAGS_v) >= verbose_level
: **vmodule_info >= verbose_level;
}
} // namespace google

View File

@@ -1,82 +0,0 @@
// Copyright 2010-2024 Google LLC
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#ifndef OR_TOOLS_BASE_VLOG_IS_ON_H_
#define OR_TOOLS_BASE_VLOG_IS_ON_H_
#include <cstdint>
#include "absl/flags/declare.h"
#include "absl/log/log.h"
ABSL_DECLARE_FLAG(int, v);
namespace google {
#if defined(__GNUC__)
// We emit an anonymous static int* variable at every VLOG_IS_ON(n) site.
// (Normally) the first time every VLOG_IS_ON(n) site is hit,
// we determine what variable will dynamically control logging at this site:
// it's either absl::GetFlag(FLAGS_v) or an appropriate internal variable
// matching the current source file that represents results of
// parsing of --vmodule flag and/or SetVLOGLevel calls.
#define VLOG_IS_ON(verboselevel) \
__extension__({ \
static bool vmodule_initialized__ = false; \
static int32_t* vmodule_info__ = nullptr; \
int32_t verbose_level__ = (verboselevel); \
(vmodule_initialized__ \
? (vmodule_info__ == nullptr \
? absl::GetFlag(FLAGS_v) >= verbose_level__ \
: *vmodule_info__ >= verbose_level__) \
: google::InitVLOG3__(&vmodule_info__, &vmodule_initialized__, \
__FILE__, verbose_level__)); \
})
#else
// GNU extensions not available, so we do not support --vmodule.
// Dynamic value of absl::GetFlag(FLAGS_v) always controls the logging level.
#define VLOG_IS_ON(verboselevel) (absl::GetFlag(FLAGS_v) >= (verboselevel))
#endif
// Set VLOG(_IS_ON) level for module_pattern to log_level.
// This lets us dynamically control what is normally set by the --vmodule flag.
// Returns the level that previously applied to module_pattern.
// NOTE: To change the log level for VLOG(_IS_ON) sites
// that have already executed after/during InitGoogleLogging,
//. one needs to supply the exact --vmodule pattern that applied to them.
// (If no --vmodule pattern applied to them
// the value of FLAGS_v will continue to control them.)
extern int SetVLOGLevel(const char* module_pattern, int log_level);
// Various declarations needed for VLOG_IS_ON above: =========================
// Special value used to indicate that a VLOG_IS_ON site has not been
// initialized. We make this a large value, so the common-case check
// of "*vlocal__ >= verbose_level__" in VLOG_IS_ON definition
// passes in such cases and InitVLOG3__ is then triggered.
extern int32_t kLogSiteUninitialized;
// Helper routine which determines the logging info for a particalur VLOG site.
// get_level is a function that returns the log level
// initialized is a boolean value that tells if vmodule was initialized
// for that file.
// fname is the current source file name
// verbose_level is the argument to VLOG_IS_ON
// We will return the return value for VLOG_IS_ON
// and if possible set *site_flag appropriately.
extern bool InitVLOG3__(int32_t** vmodule_info, bool* initialized,
const char* fname, int32_t verbose_level);
} // namespace google
#endif // OR_TOOLS_BASE_VLOG_IS_ON_H_

View File

@@ -1,49 +0,0 @@
diff --git a/CMake/AbseilDll.cmake b/CMake/AbseilDll.cmake
index f0d984ae..9134696d 100644
--- a/CMake/AbseilDll.cmake
+++ b/CMake/AbseilDll.cmake
@@ -624,23 +624,33 @@ set(ABSL_INTERNAL_TEST_DLL_TARGETS
include(CheckCXXSourceCompiles)
-check_cxx_source_compiles(
- [==[
-#ifdef _MSC_VER
-# if _MSVC_LANG < 201700L
-# error "The compiler defaults or is configured for C++ < 17"
-# endif
-#elif __cplusplus < 201700L
-# error "The compiler defaults or is configured for C++ < 17"
-#endif
-int main() { return 0; }
-]==]
+message(WARNING "ABSL_CXX_STANDARD: ${ABSL_CXX_STANDARD}")
+message(WARNING "CMAKE_CXX_STANDARD: ${CMAKE_CXX_STANDARD}")
+message(WARNING "CMAKE_CXX_STANDARD_REQUIRED: ${CMAKE_CXX_STANDARD_REQUIRED}")
+message(WARNING "CMAKE_CXX_FLAGS: ${CMAKE_CXX_FLAGS}")
+
+if(CMAKE_CXX_STANDARD GREATER_EQUAL 17)
+ set(ABSL_INTERNAL_AT_LEAST_CXX17 TRUE)
+else()
+ check_cxx_source_compiles(
+ [==[
+ #ifdef _MSC_VER
+ # if _MSVC_LANG < 201700L
+ # error "The compiler defaults or is configured for C++ < 17"
+ # endif
+ #elif __cplusplus < 201700L
+ # error "The compiler defaults or is configured for C++ < 17"
+ #endif
+ int main() { return 0; }
+ ]==]
ABSL_INTERNAL_AT_LEAST_CXX17)
+endif()
if(ABSL_INTERNAL_AT_LEAST_CXX17)
set(ABSL_INTERNAL_CXX_STD_FEATURE cxx_std_17)
else()
set(ABSL_INTERNAL_CXX_STD_FEATURE cxx_std_14)
+ message(FATAL_ERROR "Should not pass here !!!")
endif()
function(absl_internal_dll_contains)

View File

@@ -2,8 +2,31 @@ diff --git a/src/lpi/lpi_glop.cpp b/src/lpi/lpi_glop.cpp
index 2471778a8f..17fd1e8c34 100644
--- a/src/lpi/lpi_glop.cpp
+++ b/src/lpi/lpi_glop.cpp
@@ -3190,7 +3190,7 @@ SCIP_RETCODE SCIPlpiReadLP(
@@ -51,7 +51,6 @@
#include "ortools/util/time_limit.h"
#include "ortools/base/logging.h"
-#include "ortools/base/vlog_is_on.h"
#include "lpi/lpi.h"
#include "scip/pub_message.h"
@@ -2942,12 +2941,12 @@ SCIP_RETCODE SCIPlpiSetIntpar(
SCIPdebugMessage("SCIPlpiSetIntpar: SCIP_LPPAR_LPINFO -> %d.\n", ival);
if ( ival == 0 )
{
- (void) google::SetVLOGLevel("*", google::GLOG_INFO);
+ absl::SetFlag(&FLAGS_stderrthreshold, 2);
lpi->lp_info = false;
}
else
{
- (void) google::SetVLOGLevel("*", google::GLOG_ERROR);
+ absl::SetFlag(&FLAGS_stderrthreshold, 0);
lpi->lp_info = true;
}
break;
@@ -3190,7 +3189,7 @@ SCIP_RETCODE SCIPlpiReadLP(
const std::string filespec(fname);
MPModelProto proto;
- if ( ! ReadFileToProto(filespec, &proto) )
@@ -11,7 +34,7 @@ index 2471778a8f..17fd1e8c34 100644
{
SCIPerrorMessage("Could not read <%s>\n", fname);
return SCIP_READERROR;
@@ -3214,7 +3214,7 @@ SCIP_RETCODE SCIPlpiWriteLP(
@@ -3214,6 +3213,6 @@ SCIP_RETCODE SCIPlpiWriteLP(
MPModelProto proto;
LinearProgramToMPModelProto(*lpi->linear_program, &proto);
const std::string filespec(fname);
@@ -19,5 +42,4 @@ index 2471778a8f..17fd1e8c34 100644
+ if ( ! WriteProtoToFile(filespec, proto, operations_research::ProtoWriteFormat::kProtoText, true).ok() )
{
SCIPerrorMessage("Could not write <%s>\n", fname);
return SCIP_READERROR;
return SCIP_READERROR;