open-quantum-safe / liboqs

C library for prototyping and experimenting with quantum-resistant cryptography
https://openquantumsafe.org/
Other
1.92k stars 466 forks source link

CMAKE_POSITION_INDEPENDENT_CODE should be optional #1882

Open DavidHorton5339 opened 3 months ago

DavidHorton5339 commented 3 months ago

In order to use OQS for an embedded target (which does not use dynamic linking, and hence does not provision a Global Offset Table or Procedure Linkage Table), I would like to build it as a static library with CMAKE_POSITION_INDEPENDENT_CODE set OFF. However, the CMakeLists.txt hard codes this to ON, with no capability to override. It would be useful to allow this setting to be chosen from externally, for example in the CMake toolchain file. It should be noted that CMake's default choice in the absence of a setting is usually a sensible one (depending on the type of library or executable being built).

SWilson4 commented 3 months ago

I dug through the git blame to see why we would have hardcoded this, and it led me to PR #670, citing OpenSSL build failures. I believe that PR predated oqs-provider, so presumably it refers to our deprecated OpenSSL fork. Any idea if hardcoding the option is still necessary @baentsch @christianpaquin?

baentsch commented 3 months ago

Good "dig" @SWilson4 . Yes, the rationale given by @kevinmkane in 2020 seems sensible when building liboqs embedded into openssl -- and the PR definitely predates oqsprovider... which typically is a shared lib, though... ;-) But seriously, AFAIK oqsprovider can be configured to be built statically as well as shared, so hard-coding -fPIC does not seem a pre-requisite any more these days (and also shouldn't be).