This is the mail archive of the java@gcc.gnu.org mailing list for the Java project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: CNI and interface methods


Stephen Kell wrote:
> On Fri, 03 Apr 2009 09:37:40 +0100, Andrew Haley wrote:
>> It's because you're using -Bsymbolic but not -fpic.  -Bsymbolic is
>> dangerous, and any use of it without PIC means instant death.  So,
>> compile everything PIC, even the executable, and you'll be fine.
>> That worked for me on your example.
> 
> Thanks for this. I thought I already was compiling everything -fpic,
> but maybe I missed something. Was there a particular make rule that was
> in need of -fpic, that you altered?  I still can't find it.
> 
> (Actually I was using -fPIC, but I've tried again with -fpic instead, in
> case it made a difference... still getting the same segfault though.)

Here are my changes.  I also got rid of antlr-runtime which didn't seem
necessary.

Andrew.


--- Makefile~   2009-04-02 19:31:29.000000000 +0100
+++ Makefile    2009-04-03 09:31:06.000000000 +0100
@@ -16,13 +16,13 @@
 default: cake

 %.o: %.cpp
-       g++ -c -o "$@" ${CXXFLAGS} "$<"
+       g++ -c -fpic -o "$@" ${CXXFLAGS} "$<"

 main.o: main.cpp parser-recursive Makefile antlr-headers
-       g++ -c -o "$@" ${CXXFLAGS} "$<"
+       g++ -c -fpic -o "$@" ${CXXFLAGS} "$<"

-cake: main.o $(OBJS) antlr-runtime-3.1.jar.so stringtemplate-3.2.jar.so antlr-3.1.2.jar.so junit-3.8.2.jar.so
-       gcj $(GCJFLAGS) -Wl,-R. -o "$@" $(OBJS) "$<" -lstdc++ parser/cakeJava{Parser,Lexer}*.o antlr-runtime-3.1.jar.so stringtemplate-3.2.jar.so antlr-3.1.2.jar.so junit-3.8.2.jar.so
+cake: main.o $(OBJS) stringtemplate-3.2.jar.so antlr-3.1.2.jar.so junit-3.8.2.jar.so
+       gcj $(GCJFLAGS) -Wl,-R. -o "$@" $(OBJS) "$<" -lstdc++ parser/cakeJava{Parser,Lexer}*.o stringtemplate-3.2.jar.so antlr-3.1.2.jar.so junit-3.8.2.jar.so

 # FIXME: to build, change the following .jar paths

@@ -41,14 +41,14 @@
                org.antlr.runtime.IntStream

 %.jar.so: %.jar
-       gcj $(GCJFLAGS) -shared -fPIC -Wl,-Bsymbolic "$<" -o "$@"
+       gcj $(GCJFLAGS) -shared -g -fPIC -Wl,-Bsymbolic "$<" -o "$@"

 #java-headers:
 #      gcjh -d gcjh_generated -classpath .:$(CLASSPATH) java.io.File java.io.FileInputStream

 .PHONY: parser-recursive
 parser-recursive:
-       $(MAKE) -C parser
+       $(MAKE) -C parser CLASSPATH=$(CLASSPATH)

 .PHONY: clean
 clean:
--- parser/Makefile~    2009-04-02 19:32:24.000000000 +0100
+++ parser/Makefile     2009-04-03 09:31:06.000000000 +0100
@@ -33,14 +33,14 @@
        $(ANTLR) "$<"

 %.class: %.java
-       gcj -MD -C -Wno-unused "$<"
+       gcj -g -MD -C -Wno-unused "$<"

 %.o: %.class
-       gcj $(JFLAGS) -MD -Wno-unused -c -o "$@" "$<"
+       gcj $(JFLAGS) -MD -Wno-unused -c -o "$@" "$<" -g -fpic
 # HACK: also make nested classes' object files, because we can't enumerate these statically for Makefile purposes
        for classfile in "$*"\$$*.class; do \
                if [[ $$classfile != "$*"\$$"*".class ]]; then \
-                       gcj -o $$( echo "$$classfile" | sed 's/class$$/o/') -MD -Wno-unused -c "$$classfile"; \
+                       gcj -o $$( echo "$$classfile" | sed 's/class$$/o/') -MD -Wno-unused -fpic -c "$$classfile"; \
                fi; \
        done


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]