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

Building shared libs issue #1

Open
senseyman opened this issue Jul 14, 2023 · 0 comments
Open

Building shared libs issue #1

senseyman opened this issue Jul 14, 2023 · 0 comments

Comments

@senseyman
Copy link

Hello. guys!
I'm trying to build those source files to .so shared libs to use it in Golang, but have some issues.
Here is my Makefile

# Compiler settings
CC := gcc
CFLAGS := -std=c99 -no-pie -mavx2 -g -O3 -Wall -Wextra -Werror -fPIC -Wno-error=sign-compare -Wno-error=unused-parameter
ASMFLAGS := -fPIC

# Directories
SRCDIR := source/avx2
OBJDIR := obj
LIBDIR := lib

# Source files
CFILES := $(wildcard $(SRCDIR)/*.c)
SFILES := $(wildcard $(SRCDIR)/*.s)

# Object files
COBJECTS := $(patsubst $(SRCDIR)/%.c, $(OBJDIR)/%.o, $(CFILES))
SOBJECTS := $(patsubst $(SRCDIR)/%.s, $(OBJDIR)/%.o, $(SFILES))

# Shared library name
LIBRARY := libavx2.so

all: $(LIBDIR)/$(LIBRARY)

# Compile C files
$(OBJDIR)/%.o: $(SRCDIR)/%.c
	$(CC) $(CFLAGS) -c -o $@ $<

# Assemble S files
$(OBJDIR)/%.o: $(SRCDIR)/%.s
	$(CC) $(ASMFLAGS) -c -o $@ $<

# Build shared library
$(LIBDIR)/$(LIBRARY): $(COBJECTS) $(SOBJECTS)
	$(CC) -shared -Wl,-Bsymbolic-functions -Wl,-z,relro -o $@ $^


clean:
	rm -f $(OBJDIR)/*.o
	rm -f $(LIBDIR)/$(LIBRARY)

But when I run it, I have next errors:
/usr/bin/ld: obj/genfullchain8x.o: relocation R_X86_64_32S against symbol _rotate8' can not be used when making a shared object; recompile with -fPIC`

As you can see, I'm building .s files with flag -fPIC but the compiler still tells me that there is an issue.

Can you help me with it?

Would be awesome if you add some instruction and tech specs to your README how to use your library.

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

No branches or pull requests

1 participant