Fix Makefile to use custom-built GCC 10 instead of non-existent gcc-toolset-10

- Replace 'scl enable gcc-toolset-10' with 'bash -l' (login shell)
- Login shell sources /etc/profile.d/cuda-11.4.sh and go.sh for PATH
- Explicitly set CC=/usr/local/bin/gcc CXX=/usr/local/bin/g++ (custom-built GCC 10)
- Fix run-cmake, run-build, run-go-build, and shell targets
- Enables CMake to find nvcc and use correct compiler toolchain
This commit is contained in:
Shang Chieh Tseng
2025-11-08 21:20:26 +08:00
parent f2c94bb9af
commit 6237498297

View File

@@ -122,19 +122,19 @@ copy-source: start-builder
run-cmake: copy-source
@echo "→ Running CMake configuration (preset: $(CMAKE_PRESET))..."
@docker exec -w /usr/local/src/ollama37 $(CONTAINER_NAME) \
scl enable gcc-toolset-10 -- bash -c 'cmake --preset "$(CMAKE_PRESET)"'
bash -l -c 'CC=/usr/local/bin/gcc CXX=/usr/local/bin/g++ cmake --preset "$(CMAKE_PRESET)"'
# Run CMake build (C/C++/CUDA compilation)
run-build: run-cmake
@echo "→ Building C/C++/CUDA libraries (using $(NPROC) cores)..."
@docker exec -w /usr/local/src/ollama37 $(CONTAINER_NAME) \
scl enable gcc-toolset-10 -- bash -c 'cmake --build build -j$(NPROC)'
bash -l -c 'CC=/usr/local/bin/gcc CXX=/usr/local/bin/g++ cmake --build build -j$(NPROC)'
# Run Go build
run-go-build: run-build
@echo "→ Building Go binary..."
@docker exec -w /usr/local/src/ollama37 $(CONTAINER_NAME) \
scl enable gcc-toolset-10 -- bash -c 'go build -o ollama .'
bash -l -c 'go build -o ollama .'
# Copy build artifacts from container to host
copy-artifacts: run-go-build
@@ -153,8 +153,7 @@ copy-artifacts: run-go-build
# Open an interactive shell in the builder container
shell: start-builder
@echo "→ Opening shell in builder container..."
@docker exec -it -w /usr/local/src/ollama37 $(CONTAINER_NAME) \
scl enable gcc-toolset-10 -- bash
@docker exec -it -w /usr/local/src/ollama37 $(CONTAINER_NAME) bash -l
# Test the built binary
test: build