Adjust Makefiles to support cross-compilation
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 4/5
- Tiempo estimado
- 3-5 días
- Aptitud para principiantes
- 42/100
- Tipo de issue
- Nueva funcionalidad
- Claridad
- Bien especificado
- Estado de actividad
- Estancado
- Stack tecnológico
- cpp
- Área
- build-system
Línea de trabajo
Comienza por stan/lib/stan_math/make/compiler_flags y stan/lib/stan_math/make/libraries, y luego inspecciona los Makefiles de TBB referenciados bajo build/. Ejecuta los Make targets existentes con un TARGET_OS diferente al del host y verifica que los sufijos específicos de la plataforma, los flags y las compilaciones de TBB utilicen el sistema operativo de destino.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
Summary:
Allow setting a new variable, TARGET_OS, which is used instead of OS when it determines a property of the compiled files.
Description:
The existing codebase assumes that the current OS is the same as the OS that will be running the compiled program. This is not always the case. In my case I am running macOS but running my Stan programs on Linux.
I'm including the patch I've come up with here, in case it's helpful to others.
diff --git a/stan/lib/stan_math/make/compiler_flags b/stan/lib/stan_math/make/compiler_flags
index 8106f58b..4cf67576 100644
--- a/stan/lib/stan_math/make/compiler_flags
+++ b/stan/lib/stan_math/make/compiler_flags
@@ -15,16 +15,19 @@ ifneq ($(OS),Windows_NT)
OS := $(shell uname -s)
endif
+## Allow cross compiling to another target operating system
+TARGET_OS ?= $(OS)
+
## Set OS specific library filename extensions
-ifeq ($(OS),Windows_NT)
+ifeq ($(TARGET_OS),Windows_NT)
LIBRARY_SUFFIX ?= .dll
endif
-ifeq ($(OS),Darwin)
+ifeq ($(TARGET_OS),Darwin)
LIBRARY_SUFFIX ?= .dylib
endif
-ifeq ($(OS),Linux)
+ifeq ($(TARGET_OS),Linux)
LIBRARY_SUFFIX ?= .so
endif
@@ -145,7 +148,7 @@ CXXFLAGS_SUNDIALS ?= -pipe $(CXXFLAGS_OPTIM_SUNDIALS) $(CPPFLAGS_FLTO_SUNDIALS)
################################################################################
# Update compiler flags with operating system specific modifications
##
-ifeq ($(OS),Windows_NT)
+ifeq ($(TARGET_OS),Windows_NT)
CXXFLAGS_WARNINGS ?= -Wall -Wno-unused-function -Wno-uninitialized -Wno-unused-but-set-variable -Wno-unused-variable -Wno-sign-compare -Wno-unused-local-typedefs -Wno-int-in-bool-context -Wno-attributes
CPPFLAGS_GTEST ?= -DGTEST_HAS_PTHREAD=0
CPPFLAGS_OS ?= -D_USE_MATH_DEFINES
@@ -166,13 +169,13 @@ ifeq ($(OS),Windows_NT)
EXE := .exe
endif
-ifeq ($(OS),Darwin)
+ifeq ($(TARGET_OS),Darwin)
ifeq (clang,$(CXX_TYPE))
CXXFLAGS_OS ?= -Wno-unknown-warning-option -Wno-tautological-compare -Wno-sign-compare
endif
endif
-ifeq ($(OS),Linux)
+ifeq ($(TARGET_OS),Linux)
CPPFLAGS_GTEST ?= -DGTEST_HAS_PTHREAD=0
CXXFLAGS_WARNINGS ?= -Wno-sign-compare
ifeq (gcc,$(CXX_TYPE))
@@ -252,13 +255,13 @@ LDLIBS_TBB ?=
else
-ifeq ($(OS),Windows_NT)
+ifeq ($(TARGET_OS),Windows_NT)
TBB_TARGETS ?= $(addprefix $(TBB_BIN)/,$(addsuffix $(LIBRARY_SUFFIX),$(TBB_LIBRARIES)))
endif
-ifeq ($(OS),Darwin)
+ifeq ($(TARGET_OS),Darwin)
TBB_TARGETS ?= $(addprefix $(TBB_BIN)/lib,$(addsuffix $(LIBRARY_SUFFIX), $(TBB_LIBRARIES)))
endif
-ifeq ($(OS),Linux)
+ifeq ($(TARGET_OS),Linux)
# Update the suffix with the internal TBB source code!
# The new version of TBB library is 12+ (e.g., libtbb.so.12.1 not libtbb.so.2)
TBB_TARGETS ?= $(addprefix $(TBB_BIN)/lib,$(addsuffix $(LIBRARY_SUFFIX).2,$(TBB_LIBRARIES)))
diff --git a/stan/lib/stan_math/make/libraries b/stan/lib/stan_math/make/libraries
index fcababa0..325ab05c 100644
--- a/stan/lib/stan_math/make/libraries
+++ b/stan/lib/stan_math/make/libraries
@@ -119,6 +119,8 @@ ifeq ($(CXX_TYPE),other)
endif
TBB_CXX_TYPE ?= $(CXX_TYPE)
+TBB_OS ?= $(shell echo $(TARGET_OS) | tr '[:upper:]' '[:lower:]')
+
# Set c compiler used for the TBB
ifeq (clang,$(CXX_TYPE))
TBB_CC ?= $(subst clang++,clang,$(CXX))
@@ -166,11 +168,11 @@ endif
$(TBB_BIN)/tbb.def: $(TBB_BIN)/tbb-make-check $(TBB_BIN)/tbbmalloc.def
@mkdir -p $(TBB_BIN)
touch $(TBB_BIN)/version_$(notdir $(TBB))
- tbb_root="$(TBB_RELATIVE_PATH)" CXX="$(CXX)" CC="$(TBB_CC)" LDFLAGS='$(LDFLAGS_TBB)' '$(MAKE)' -C "$(TBB_BIN)" -r -f "$(TBB_ABSOLUTE_PATH)/build/Makefile.tbb" compiler=$(TBB_CXX_TYPE) cfg=release stdver=c++1y CXXFLAGS="$(TBB_CXXFLAGS)"
+ tbb_root="$(TBB_RELATIVE_PATH)" CXX="$(CXX)" CC="$(TBB_CC)" LDFLAGS='$(LDFLAGS_TBB)' '$(MAKE)' -C "$(TBB_BIN)" -r -f "$(TBB_ABSOLUTE_PATH)/build/Makefile.tbb" compiler=$(TBB_CXX_TYPE) tbb_os=$(TBB_OS) cfg=release stdver=c++1y CXXFLAGS="$(TBB_CXXFLAGS)"
$(TBB_BIN)/tbbmalloc.def: $(TBB_BIN)/tbb-make-check
@mkdir -p $(TBB_BIN)
- tbb_root="$(TBB_RELATIVE_PATH)" CXX="$(CXX)" CC="$(TBB_CC)" LDFLAGS='$(LDFLAGS_TBB)' '$(MAKE)' -C "$(TBB_BIN)" -r -f "$(TBB_ABSOLUTE_PATH)/build/Makefile.tbbmalloc" compiler=$(TBB_CXX_TYPE) cfg=release stdver=c++1y malloc CXXFLAGS="$(TBB_CXXFLAGS)"
+ tbb_root="$(TBB_RELATIVE_PATH)" CXX="$(CXX)" CC="$(TBB_CC)" LDFLAGS='$(LDFLAGS_TBB)' '$(MAKE)' -C "$(TBB_BIN)" -r -f "$(TBB_ABSOLUTE_PATH)/build/Makefile.tbbmalloc" compiler=$(TBB_CXX_TYPE) tbb_os=$(TBB_OS) cfg=release stdver=c++1y malloc CXXFLAGS="$(TBB_CXXFLAGS)"
$(TBB_BIN)/libtbb.dylib: $(TBB_BIN)/tbb.def
$(TBB_BIN)/libtbbmalloc.dylib: $(TBB_BIN)/tbbmalloc.def
Note that this patch assumes that you have also set a number of other environment variables to reasonable values. In my case that has meant setting:
CXXCXXFLAGS_PROGRAMCXXFLAGS_LANGCXXFLAGSCXXFLAGS_OPTIM_TBBLDFLAGS_TBB
Current Version:
v2.26.1
- Lenguaje dominante
- C++
- Estrellas
- 240
- Forks
- 105
- Métricas de merge de PR
- Sin PR fusionados en 30 d
Preparar el entorno
- Sin Dockerfile ni archivo de Docker Compose
- Tiene una plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de stan-dev/cmdstan
-
Release CmdStan 2.40Abierto
Dificultad 4/5 3-5 días Aptitud para principiantes 35/100
-
bug
Dificultad 1/5 Menos de una hora Aptitud para principiantes 55/100
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 45/100
-
code-cleanup
Dificultad 4/5 3-5 días Aptitud para principiantes 35/100
-
diagnose exit codeAbierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 52/100
Todos los issues de stan-dev/cmdstan
Issues similares
-
Upstream changes to reviewAbierto
Dificultad 1/5 Menos de una hora Aptitud para principiantes 72/100
rhalbersma/xstd-ints#395 ·
Los mantenedores suelen responder en 1 día
-
[Bug] Root filesystem scope (/) incorrectly rejects all descendant pathsPosiblemente ocupada @mugenkyou la tomó hoy. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
neutralinojs/neutralino.js#304 · 1 comentario ·
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
Los mantenedores suelen responder en 1 día
-
FuSa
Dificultad 2/5 1-3 horas Aptitud para principiantes 76/100
tenstorrent/tt-umd#3851 ·
Los mantenedores suelen responder en 3 días
-
zq prints a raw SQL 'no such table: index_default' error when the index has no default indexAbiertobug
Dificultad 2/5 1-3 horas Aptitud para principiantes 73/100
mattgodbolt/zindex#67 ·
Los mantenedores suelen responder en 1 día