From 983939a9b8e3f41ba512e8403646df1bafd57909 Mon Sep 17 00:00:00 2001 From: sugarme Date: Wed, 29 Nov 2023 20:55:15 +1100 Subject: [PATCH] clean up cgo flags --- CHANGELOG.md | 1 + libtch/lib.go | 9 ++++----- setup-gotch.sh | 15 +++++++-------- 3 files changed, 12 insertions(+), 13 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1c8360f..3fe5931 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). ## [Unreleased] +- Tidy up cgo flags ## [Nofix] - ctype `long` caused compiling error in MacOS as noted on [#44]. Not working on linux box. diff --git a/libtch/lib.go b/libtch/lib.go index 4f22530..b67e375 100644 --- a/libtch/lib.go +++ b/libtch/lib.go @@ -1,10 +1,9 @@ package libtch -// #cgo LDFLAGS: -lstdc++ -ltorch -lc10 -ltorch_cpu -L${SRCDIR}/libtorch/lib -// #cgo LDFLAGS: -L/usr/local/cuda/lib64 -lcuda -lcudart -lcublas -lcudnn -lcaffe2_nvrtc -lnvrtc-builtins -lnvrtc -lnvToolsExt -lc10_cuda -ltorch_cuda // #cgo CFLAGS: -I${SRCDIR} -O3 -Wall -Wno-unused-variable -Wno-deprecated-declarations -Wno-c++11-narrowing -g -Wno-sign-compare -Wno-unused-function -// #cgo CFLAGS: -D_GLIBCXX_USE_CXX11_ABI=0 // #cgo CFLAGS: -I/usr/local/cuda/include -// #cgo CXXFLAGS: -std=c++17 -I${SRCDIR} -g -O3 -// #cgo CXXFLAGS: -I${SRCDIR}/libtorch/lib -I${SRCDIR}/libtorch/include -I${SRCDIR}/libtorch/include/torch/csrc/api/include +// #cgo LDFLAGS: -lstdc++ -ltorch -ltorch_cpu -ltorch_cuda -lc10 +// #cgo LDFLAGS: -L/usr/local/cuda/lib64 -lcuda +// #cgo CFLAGS: -D_GLIBCXX_USE_CXX11_ABI=1 +// #cgo CXXFLAGS: -std=c++17 import "C" diff --git a/setup-gotch.sh b/setup-gotch.sh index 42002f5..3c72e96 100644 --- a/setup-gotch.sh +++ b/setup-gotch.sh @@ -45,10 +45,7 @@ package libtch // #cgo CFLAGS: -I/usr/local/include // #cgo CFLAGS: -D_GLIBCXX_USE_CXX11_ABI=1 // #cgo LDFLAGS: -lstdc++ -ltorch -lc10 -ltorch_cpu -L/lib64 -// #cgo CXXFLAGS: -std=c++17 -I${SRCDIR} -g -O3 -// #cgo CFLAGS: -I${SRCDIR}/libtorch/lib -I${SRCDIR}/libtorch/include -I${SRCDIR}/libtorch/include/torch/csrc/api/include -I${SRCDIR}/libtorch/include/torch/csrc -// #cgo LDFLAGS: -L${SRCDIR}/libtorch/lib -// #cgo CXXFLAGS: -I${SRCDIR}/libtorch/lib -I${SRCDIR}/libtorch/include -I${SRCDIR}/libtorch/include/torch/csrc/api/include -I${SRCDIR}/libtorch/include/torch/csrc +// #cgo CXXFLAGS: -std=c++17 import "C" EOT else @@ -56,12 +53,14 @@ else sudo tee -a $GOTCH_LIB_FILE > /dev/null <