CoinMP: backport build fixes for musl-libc (#313603)

This commit is contained in:
Yureka 2024-05-24 10:10:54 +02:00 committed by GitHub
parent 69aa70cddf
commit f90996a6df
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 163 additions and 1 deletions

@ -0,0 +1,95 @@
From 0259f2b936ee0d9288ff39c509c69a66f5b13b80 Mon Sep 17 00:00:00 2001
From: Stefan Vigerske <svigerske@gams.com>
Date: Mon, 11 Mar 2019 16:34:25 +0000
Subject: [PATCH 1/2] change more reinterpret_cast from NULL to C-cast, see
also #93
---
Clp/src/AbcSimplex.cpp | 48 +++++++++++++++++++++---------------------
Clp/src/ClpModel.cpp | 2 +-
2 files changed, 25 insertions(+), 25 deletions(-)
diff --git a/Clp/src/AbcSimplex.cpp b/Clp/src/AbcSimplex.cpp
index 0eacd91e..1715e6d8 100644
--- a/Clp/src/AbcSimplex.cpp
+++ b/Clp/src/AbcSimplex.cpp
@@ -368,19 +368,19 @@ AbcSimplex::gutsOfInitialize(int numberRows,int numberColumns,bool doMore)
// say Steepest pricing
abcDualRowPivot_ = new AbcDualRowSteepest();
abcPrimalColumnPivot_ = new AbcPrimalColumnSteepest();
- internalStatus_ = newArray(reinterpret_cast<unsigned char *>(NULL),
+ internalStatus_ = newArray((unsigned char *)NULL,
sizeArray+maximumNumberTotal_);
- abcLower_ = newArray(reinterpret_cast<double *>(NULL),sizeArray);
- abcUpper_ = newArray(reinterpret_cast<double *>(NULL),sizeArray);
- abcCost_ = newArray(reinterpret_cast<double *>(NULL),sizeArray+maximumNumberTotal_);
- abcDj_ = newArray(reinterpret_cast<double *>(NULL),sizeArray);
- abcSolution_ = newArray(reinterpret_cast<double *>(NULL),sizeArray+maximumNumberTotal_);
- //fromExternal_ = newArray(reinterpret_cast<int *>(NULL),sizeArray);
- //toExternal_ = newArray(reinterpret_cast<int *>(NULL),sizeArray);
- scaleFromExternal_ = newArray(reinterpret_cast<double *>(NULL),sizeArray);
- offset_ = newArray(reinterpret_cast<double *>(NULL),sizeArray);
- abcPerturbation_ = newArray(reinterpret_cast<double *>(NULL),sizeArray);
- abcPivotVariable_ = newArray(reinterpret_cast<int *>(NULL),maximumAbcNumberRows_);
+ abcLower_ = newArray((double *)NULL,sizeArray);
+ abcUpper_ = newArray((double *)NULL,sizeArray);
+ abcCost_ = newArray((double *)NULL,sizeArray+maximumNumberTotal_);
+ abcDj_ = newArray((double *)NULL,sizeArray);
+ abcSolution_ = newArray((double *)NULL,sizeArray+maximumNumberTotal_);
+ //fromExternal_ = newArray((int *)NULL,sizeArray);
+ //toExternal_ = newArray((int *)NULL,sizeArray);
+ scaleFromExternal_ = newArray((double *)NULL,sizeArray);
+ offset_ = newArray((double *)NULL,sizeArray);
+ abcPerturbation_ = newArray((double *)NULL,sizeArray);
+ abcPivotVariable_ = newArray((int *)NULL,maximumAbcNumberRows_);
// Fill perturbation array
setupPointers(maximumAbcNumberRows_,maximumAbcNumberColumns_);
fillPerturbation(0,maximumNumberTotal_);
@@ -554,19 +554,19 @@ AbcSimplex::createSubProblem(int numberColumns,const int * whichColumn)
subProblem->maximumNumberTotal_= maximumAbcNumberRows_+numberColumns;
subProblem->numberTotalWithoutFixed_= subProblem->numberTotal_;
int sizeArray=2*subProblem->maximumNumberTotal_+maximumAbcNumberRows_;
- subProblem->internalStatus_ = newArray(reinterpret_cast<unsigned char *>(NULL),
+ subProblem->internalStatus_ = newArray((unsigned char *)NULL,
sizeArray+subProblem->maximumNumberTotal_);
- subProblem->abcLower_ = newArray(reinterpret_cast<double *>(NULL),sizeArray);
- subProblem->abcUpper_ = newArray(reinterpret_cast<double *>(NULL),sizeArray);
- subProblem->abcCost_ = newArray(reinterpret_cast<double *>(NULL),sizeArray+subProblem->maximumNumberTotal_);
- subProblem->abcDj_ = newArray(reinterpret_cast<double *>(NULL),sizeArray);
- subProblem->abcSolution_ = newArray(reinterpret_cast<double *>(NULL),sizeArray+subProblem->maximumNumberTotal_);
- //fromExternal_ = newArray(reinterpret_cast<int *>(NULL),sizeArray);
- //toExternal_ = newArray(reinterpret_cast<int *>(NULL),sizeArray);
- subProblem->scaleFromExternal_ = newArray(reinterpret_cast<double *>(NULL),sizeArray);
- subProblem->offset_ = newArray(reinterpret_cast<double *>(NULL),sizeArray);
- subProblem->abcPerturbation_ = newArray(reinterpret_cast<double *>(NULL),sizeArray);
- subProblem->abcPivotVariable_ = newArray(reinterpret_cast<int *>(NULL),maximumAbcNumberRows_);
+ subProblem->abcLower_ = newArray((double *)NULL,sizeArray);
+ subProblem->abcUpper_ = newArray((double *)NULL,sizeArray);
+ subProblem->abcCost_ = newArray((double *)NULL,sizeArray+subProblem->maximumNumberTotal_);
+ subProblem->abcDj_ = newArray((double *)NULL,sizeArray);
+ subProblem->abcSolution_ = newArray((double *)NULL,sizeArray+subProblem->maximumNumberTotal_);
+ //fromExternal_ = newArray((int *)NULL,sizeArray);
+ //toExternal_ = newArray((int *)NULL,sizeArray);
+ subProblem->scaleFromExternal_ = newArray((double *)NULL,sizeArray);
+ subProblem->offset_ = newArray((double *)NULL,sizeArray);
+ subProblem->abcPerturbation_ = newArray((double *)NULL,sizeArray);
+ subProblem->abcPivotVariable_ = newArray((int *)NULL,maximumAbcNumberRows_);
subProblem->setupPointers(maximumAbcNumberRows_,numberColumns);
// could use arrays - but for now be safe
int * backward = new int [numberFullColumns+numberRows_];
diff --git a/Clp/src/ClpModel.cpp b/Clp/src/ClpModel.cpp
index 1fc905c4..83aa3b63 100644
--- a/Clp/src/ClpModel.cpp
+++ b/Clp/src/ClpModel.cpp
@@ -3845,7 +3845,7 @@ ClpModel::writeMps(const char *filename,
writer.setMpsData(*(matrix_->getPackedMatrix()), COIN_DBL_MAX,
getColLower(), getColUpper(),
objective,
- reinterpret_cast<const char*> (NULL) /*integrality*/,
+ (const char*)NULL /*integrality*/,
getRowLower(), getRowUpper(),
columnNames, rowNames);
// Pass in array saying if each variable integer
--
2.37.3

@ -0,0 +1,25 @@
From b36a5bd502fbf6b8ad31b6bc35c7bab4aff24313 Mon Sep 17 00:00:00 2001
From: Stefan Vigerske <svigerske@gams.com>
Date: Mon, 20 Jul 2020 18:39:20 +0200
Subject: [PATCH] use static_cast for static cast, fixes #319
---
Cbc/src/CbcModel.cpp | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/Cbc/src/CbcModel.cpp b/Cbc/src/CbcModel.cpp
index 8603942b..239bf0b4 100644
--- a/Cbc/src/CbcModel.cpp
+++ b/Cbc/src/CbcModel.cpp
@@ -5357,7 +5357,7 @@ void CbcModel::branchAndBound(int doStatistics)
OsiClpSolverInterface * clpSolver
= dynamic_cast<OsiClpSolverInterface *> (solver_);
if (clpSolver)
- clpSolver->setFakeObjective(reinterpret_cast<double *> (NULL));
+ clpSolver->setFakeObjective(static_cast<double *> (NULL));
}
#endif
moreSpecialOptions_ = saveMoreSpecialOptions;
--
2.37.3

@ -0,0 +1,26 @@
From 4571de031e528bc145590d6a1be5ceb87bd8cdb5 Mon Sep 17 00:00:00 2001
From: Stefan Vigerske <svigerske@gams.com>
Date: Mon, 11 Mar 2019 16:29:20 +0000
Subject: [PATCH 2/2] change reinterpret_cast of NULL to C-style case, fixes
#93
---
Clp/src/OsiClp/OsiClpSolverInterface.cpp | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/Clp/src/OsiClp/OsiClpSolverInterface.cpp b/Clp/src/OsiClp/OsiClpSolverInterface.cpp
index 55dd4dcd..a0217d42 100644
--- a/Clp/src/OsiClp/OsiClpSolverInterface.cpp
+++ b/Clp/src/OsiClp/OsiClpSolverInterface.cpp
@@ -1448,7 +1448,7 @@ OsiClpSolverInterface::setupForRepeatedUse(int senseOfAdventure, int printOut)
if (stopPrinting) {
CoinMessages * messagesPointer = modelPtr_->messagesPointer();
// won't even build messages
- messagesPointer->setDetailMessages(100,10000,reinterpret_cast<int *> (NULL));
+ messagesPointer->setDetailMessages(100,10000,(int*)NULL);
}
#endif
}
--
2.37.3

@ -1,4 +1,4 @@
{ lib, stdenv, fetchurl }:
{ lib, stdenv, fetchurl, fetchpatch }:
stdenv.mkDerivation rec {
pname = "CoinMP";
@ -9,6 +9,22 @@ stdenv.mkDerivation rec {
sha256 = "13d3j1sdcjzpijp4qks3n0zibk649ac3hhv88hkk8ffxrc6gnn9l";
};
patches = [
# backport build fixes for pkgsMusl.CoinMP
(fetchpatch {
url = "https://github.com/coin-or/Cgl/commit/57d8c71cd50dc27a89eaeb4672499bca55f1fd72.patch";
extraPrefix = "Cgl/";
stripLen = 1;
hash = "sha256-NdwXpIL1w6kHVfhBFscTlpriQOfUXx860/4x7pK+698=";
})
# https://github.com/coin-or/Clp/commit/b637e1d633425ae21ec041bf7f9e06f56b741de0
./0001-change-more-reinterpret_cast-from-NULL-to-C-cast-see.patch
# https://github.com/coin-or/Clp/commit/e749fe6b11a90006d744af2ca2691220862e3a59
./0002-change-reinterpret_cast-of-NULL-to-C-style-case-fixe.patch
# https://github.com/coin-or/Cbc/commit/584fd12fba6a562d49864f44bedd13ee32d06999
./0001-use-static_cast-for-static-cast-fixes-319.patch
];
enableParallelBuilding = true;
env = lib.optionalAttrs stdenv.cc.isClang {