etcimon / botan

Block & stream ciphers, public key crypto, hashing, KDF, MAC, PKCS, TLS, ASN.1, BER/DER, etc.
Other
86 stars 22 forks source link

OSX issue with botan #14

Closed dkdewitt closed 1 year ago

dkdewitt commented 8 years ago

Having trouble using botan on OSX. This my first go w/ botan so I may be missing something but I tried on debian and everything worked fine.

import botan.passhash.bcrypt;
import std.stdio;
import botan.rng.rng;
import botan.rng.auto_rng;
import memutils.unique;
void main() {
    string password = "ObJ_3fjeEtKJzNs135!4384$_29!^  _)";
    Unique!AutoSeededRNG rng = new AutoSeededRNG;

}

DMD64 D Compiler v2.071.1

DUB version 0.9.25, built on May 24 2016

dmd -of.dub/build/application-debug-posix.osx-x86_64-dmd_2071-24704D4A7E3E024137147B97F5FF9B76/btan .dub/build/application-debug-posix.osx-x86_64-dmd_2071-24704D4A7E3E024137147B97F5FF9B76/btan.o ../../../../.dub/packages/botan-1.12.5/build/libbotan_passhash.a ../../../../.dub/packages/botan-1.12.5/build/libbotan_base.a ../../../../.dub/packages/botan-math-1.0.2/build/libbotan_math.a ../../../../.dub/packages/memutils-0.4.6/libmemutils.a -L-ldl -g
ld: in ../../../../.dub/packages/botan-1.12.5/build/libbotan_base.a(unique_41f9_3b6.o), in section __TEXT,__textcoal_nt reloc 2: symbol index out of range for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
--- errorlevel 1
FAIL .dub/build/application-debug-posix.osx-x86_64-dmd_2071-24704D4A7E3E024137147B97F5FF9B76/ btan executable
dmd failed with exit code 1.
Full exception: object.Exception@source/dub/compilers/compiler.d(142): dmd failed with exit code 1.
----------------
4   dub                                 0x0000000100092807 pure @safe void std.exception.bailOut!(Exception).bailOut(immutable(char)[], ulong, const(char[])) + 123
5   dub                                 0x00000001000928e0 pure @safe bool std.exception.enforce!(Exception, bool).enforce(bool, lazy const(char)[], immutable(char)[], ulong) + 100
6   dub                                 0x00000001000aa75f void dub.compilers.compiler.Compiler.invokeTool(immutable(char)[][], void delegate(int, immutable(char)[])) + 739
7   dub                                 0x00000001000ac063 void dub.compilers.dmd.DMDCompiler.invokeLinker(const(dub.compilers.buildsettings.BuildSettings), const(dub.platform.BuildPlatform), immutable(char)[][], void delegate(int, immutable(char)[])) + 919
8   dub                                 0x00000001000bbe82 void dub.generators.build.BuildGenerator.buildWithCompiler(dub.generators.generator.GeneratorSettings, dub.compilers.buildsettings.BuildSettings) + 1974
9   dub                                 0x00000001000b92c2 bool dub.generators.build.BuildGenerator.performCachedBuild(dub.generators.generator.GeneratorSettings, dub.compilers.buildsettings.BuildSettings, const(dub.package_.Package), immutable(char)[], immutable(char)[], const(dub.package_.Package[]), const(dub.internal.vibecompat.inet.path.Path[])) + 1062
10  dub                                 0x00000001000b8cdc bool dub.generators.build.BuildGenerator.buildTarget(dub.generators.generator.GeneratorSettings, dub.compilers.buildsettings.BuildSettings, const(dub.package_.Package), immutable(char)[], const(dub.package_.Package[]), const(dub.internal.vibecompat.inet.path.Path[])) + 728
11  dub                                 0x00000001000b8814 D3dub10generators5build14BuildGenerator15generateTargetsMFS3dub10generators9generator17GeneratorSettingsxHAyaS3dub10generators9generator16ProjectGenerator10TargetInfoZ14buildTargetRecMFAyaZv + 1136
12  dub                                 0x00000001000b830a void dub.generators.build.BuildGenerator.generateTargets(dub.generators.generator.GeneratorSettings, const(dub.generators.generator.ProjectGenerator.TargetInfo[immutable(char)[]])) + 494
13  dub                                 0x00000001000c0fdf void dub.generators.generator.ProjectGenerator.generate(dub.generators.generator.GeneratorSettings) + 899
14  dub                                 0x0000000100024fb7 void dub.dub.Dub.generateProject(immutable(char)[], dub.generators.generator.GeneratorSettings) + 155
15  dub                                 0x0000000100009ca0 int dub.commandline.GenerateCommand.execute(dub.dub.Dub, immutable(char)[][], immutable(char)[][]) + 1484
16  dub                                 0x000000010000a021 int dub.commandline.BuildCommand.execute(dub.dub.Dub, immutable(char)[][], immutable(char)[][]) + 125
17  dub                                 0x000000010000a211 int dub.commandline.RunCommand.execute(dub.dub.Dub, immutable(char)[][], immutable(char)[][]) + 125
18  dub                                 0x00000001000067b7 int dub.commandline.runDubCommandLine(immutable(char)[][]) + 2755
19  dub                                 0x0000000100001887 _Dmain + 31
20  dub                                 0x00000001001b8c73 D2rt6dmain211_d_run_mainUiPPaPUAAaZiZ6runAllMFZ9__lambda1MFZv + 39
21  dub                                 0x00000001001b8ba7 void rt.dmain2._d_run_main(int, char**, extern (C) int function(char[][])*).tryExec(scope void delegate()) + 35
22  dub                                 0x00000001001b8c18 void rt.dmain2._d_run_main(int, char**, extern (C) int function(char[][])*).runAll() + 44
23  dub                                 0x00000001001b8ba7 void rt.dmain2._d_run_main(int, char**, extern (C) int function(char[][])*).tryExec(scope void delegate()) + 35
24  dub                                 0x00000001001b8b0d _d_run_main + 497
25  dub                                 0x000000010000191f main + 15
26  dub                                 0x000000010000185f start + 51
27  ???                                 0x0000000000000002 0x0 + 2
etcimon commented 8 years ago

If you definitely compiled memutils with the same compiler, it may be safe to say that this is a compiler bug on OS X that manifests specifically with botan. This library is significantly large and in its 100k+ lines of code it covers many aspects that test suites may not be covering. This being said, I would suggest using an older version like 2.070 or 2.071, or even LDC 1.0.0/.1 while I find a workaround for darwin.

dkdewitt commented 8 years ago

Cool I ran on LDC and it ran good. I'll give 070 and shot and see... Thanks

dkdewitt commented 8 years ago

So idk too much about dub but it looks like here is the what is being ran by dmd

dmd -c -of.dub/build/application-debug-posix.osx-x86_64-dmd_2071-24704D4A7E3E024137147B97F5FF9B76/btan.o -debug -g -w -version=Have_botan -version=Botan -version=CanTest -version=SHA2_32 -version=SHA2_64 -version=MD4 -version=MD5 -version=SHA1 -version=CRC24 -version=PBKDF1 -version=PBKDF2 -version=CTR_BE -version=HMAC -version=POLY1305 -version=EMSA1 -version=EMSA1_BSI -version=EMSA_X931 -version=EMSA_PKCS1 -version=EMSA_PSSR -version=EMSA_RAW -version=EME_OAEP -version=EME_PKCS1v15 -version=PBE_PKCSv20 -version=Self_Tests -version=ECB -version=CBC -version=XTS -version=OFB -version=CFB -version=AEAD_FILTER -version=AEAD_CCM -version=AEAD_EAX -version=AEAD_OCB -version=AEAD_GCM -version=AEAD_CHACHA20_POLY1305 -version=GCM_CLMUL -version=AEAD_SIV -version=RFC6979 -version=RSA -version=RW -version=DLIES -version=DSA -version=ECDSA -version=ElGamal -version=GOST_3410 -version=Curve25519 -version=Nyberg_Rueppel -version=Diffie_Hellman -version=ECDH -version=AES -version=Blowfish -version=Camellia -version=CAST -version=Cascade -version=DES -version=GOST_28147 -version=IDEA -version=KASUMI -version=LION -version=MARS -version=MISTY1 -version=NOEKEON -version=RC2 -version=RC5 -version=RC6 -version=SAFER -version=SEED -version=Serpent -version=TEA -version=Twofish -version=Threefish -version=XTEA -version=Adler32 -version=CRC32 -version=GOST_3411 -version=HAS_160 -version=Keccak -version=MD2 -version=RIPEMD_128 -version=RIPEMD_160 -version=SHA1_x86_64 -version=Skein_512 -version=Tiger -version=Whirlpool -version=ParallelHash -version=Comb4P -version=CBC_MAC -version=CMAC -version=SSL3_MAC -version=ANSI_X919_MAC -version=RC4 -version=ChaCha -version=Salsa20 -version=AES_NI -version=SIMD_SSE2 -version=AES_SSSE3 -version=Serpent_SIMD -version=SIMD_Scalar -version=Noekeon_SIMD -version=XTEA_SIMD -version=IDEA_SSE2 -version=SHA1_SSE2 -version=Engine_ASM -version=Engine_AES_ISA -version=Engine_SIMD -version=Entropy_HRTimer -version=Entropy_Rdrand -version=Entropy_DevRand -version=Entropy_EGD -version=Entropy_UnixProc -version=Entropy_Win32 -version=Entropy_ProcWalk -version=X931_RNG -version=HMAC_DRBG -version=KDF1 -version=KDF2 -version=SSL_V3_PRF -version=TLS_V10_PRF -version=TLS_V12_PRF -version=X942_PRF -version=TLS -version=X509 -version=PUBKEY -version=FPE_FE1 -version=RFC3394 -version=PassHash9 -version=BCrypt -version=SRP6 -version=TSS -version=CryptoBox -version=CryptoBox_PSK -version=ZLib -version=CryptoSafe -version=Have_btan -version=Have_botan_passhash -version=Have_botan_base -version=Have_botan_math -version=Have_memutils -Isource/ -I../../../../.dub/packages/botan-1.12.5/source/ -I../../../../.dub/packages/botan-math-1.0.2/source/ -I../../../../.dub/packages/memutils-0.4.6/memutils/source/ source/app.d -vcolumns

When i run that it compiles fine and the app runs. I see this with dub

Linking...
dmd -of.dub/build/application-debug-posix.osx-x86_64-dmd_2071-24704D4A7E3E024137147B97F5FF9B76/btan .dub/build/application-debug-posix.osx-x86_64-dmd_2071-24704D4A7E3E024137147B97F5FF9B76/btan.o ../../../../.dub/packages/botan-1.12.5/build/libbotan_passhash.a ../../../../.dub/packages/botan-1.12.5/build/libbotan_base.a ../../../../.dub/packages/botan-math-1.0.2/build/libbotan_math.a ../../../../.dub/packages/memutils-0.4.6/memutils/libmemutils.a -L-ldl -g
ld: in ../../../../.dub/packages/botan-1.12.5/build/libbotan_base.a(unique_41f9_3b6.o), in section __TEXT,__textcoal_nt reloc 2: symbol index out of range for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
--- errorlevel 1
FAIL .dub/build/application-debug-posix.osx-x86_64-dmd_2071-24704D4A7E3E024137147B97F5FF9B76/ btan executable
dmd failed with exit code 1.

So I dont know if this is a dub issue then. Homebrew is still installing Dub 0.9.25.

Anyways you know more about dub than me and I hope this info provides some more insight. If you want me to try anything lemme know...

LightBender commented 7 years ago

I can confirm that this still exists on OSX 10.12 with DMD 2.072.1. Does anybody have a work-around?

etcimon commented 7 years ago

Have you tried a plain build? --build=plain

LightBender commented 7 years ago

I use AES256_SSSE3 which appears to be missing from the plain build.

SerialVelocity commented 7 years ago

This still happens on DMD 2.074.1 :(