Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Duplicate source names give error #12

Open
NicoHood opened this issue Jul 8, 2016 · 4 comments
Open

Duplicate source names give error #12

NicoHood opened this issue Jul 8, 2016 · 4 comments
Labels

Comments

@NicoHood
Copy link
Contributor

NicoHood commented Jul 8, 2016

I try to compile those files:

avrnacl_small/crypto_auth/hmac.c 
avrnacl_small/crypto_box/curve25519xsalsa20poly1305.c 
avrnacl_small/crypto_core/hsalsa20.c 
avrnacl_small/crypto_core/salsa20.c 
avrnacl_small/crypto_dh/curve25519.c 
avrnacl_small/crypto_hash/sha512.c 
avrnacl_small/crypto_hashblocks/sha512.c 
avrnacl_small/crypto_onetimeauth/poly1305.c 
avrnacl_small/crypto_scalarmult/curve25519.c 
avrnacl_small/crypto_secretbox/xsalsa20poly1305.c 
avrnacl_small/crypto_sign/ed25519.c 
avrnacl_small/crypto_sign/sc25519.c 
avrnacl_small/crypto_sign/precompute.c 
avrnacl_small/crypto_sign/ge25519.c 
avrnacl_small/crypto_stream/xsalsa20.c 
avrnacl_small/crypto_stream/salsa20.c 
avrnacl_small/crypto_verify/verify.c

But I get this error:

dmbs/DMBS/gcc.mk:95: *** Cannot build with OBJDIR parameter set - one or more object file name is not unique.  Stop.

If you look closer at the sources you will notice that sha512.c (and others) are available in two folders (but still different code inside). I think the folder structure is not kept in the output path and therefor this causes problems.

Using latest dmbs release-20160403 or newer (from git).

@NicoHood
Copy link
Contributor Author

NicoHood commented Jul 8, 2016

This is my patch (not sure if its good like this, but "it works")

# Check if an output object file directory was specified instead of the input file location
ifneq ($(OBJDIR),.)
   # Prefix all the object filenames with the output object file directory path
   OBJECT_FILES    := $(addprefix $(patsubst %/,%,$(OBJDIR))/, $(OBJECT_FILES))
   OBJECT_PATH := $(dir $(OBJECT_FILES))
   $(shell mkdir -p $(OBJECT_PATH))

   # Create the output object file directory if it does not exist and add it to the virtual path list
   $(shell mkdir $(OBJDIR) 2> /dev/null)
   VPATH           += $(dir $(SRC))
endif

@abcminiuser
Copy link
Owner

abcminiuser commented Oct 4, 2016

Sorry, I really haven't been looking at Github for ages - too much paid work that leaves me too unmotivated to look at my personal projects :(.

Just took a look at this. The issue with multiple object files with identical names is a very hard one to solve, specifically because of relative paths. Give SRC of:

SRC = Test.c ../Library/Test.c

The resulting objects will be:

Test.o ../Library/Test.o

Which is fine to build in place. Unfortunately however, you can't easily rebase that path against a new object path in GNU make as far as I am aware, so simply adding a common OBJDIR prefix $(addprefix $(patsubst %/,%,$(OBJDIR))/, $(OBJECT_FILES)) results in:

obj/Test.o obj/../Library/Test.o

I.e. objects are generated outside the desired root OBJDIR folder. That's why I enforce the unique name constraint on the input source files if you want to put all the objects into a flat OBJDIR directly - stripping off the full base path of the input source files sidesteps the relative pathing issue.

@NicoHood
Copy link
Contributor Author

NicoHood commented Oct 4, 2016

You could possibly check for duplicate names and then name them with Test_1 Test_2? Or you could add a hash before each file which would be unique enough. A small CRC would not give too much trash output and serve the needs.

@NicoHood
Copy link
Contributor Author

And what if we just replace ".." by "rel" and create this path?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants