# Compiling 1.9.1p0 on AIX 5.3 using xlc

**URL:** <https://www.ruby-forum.com/t/compiling-1-9-1p0-on-aix-5-3-using-xlc/161997>\
**Category:** Ruby\
**Created:** [March 4, 2009, 4:55pm UTC](https://www.ruby-forum.com/t/compiling-1-9-1p0-on-aix-5-3-using-xlc/161997 "2009-03-04T16:55:26Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![graza](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/838e76/32.png) [@graza](https://www.ruby-forum.com/u/graza)\
**Post date:** [March 4, 2009, 4:55pm UTC](https://www.ruby-forum.com/t/compiling-1-9-1p0-on-aix-5-3-using-xlc/161997/1 "2009-03-04T16:55:26Z")

</div>

Hi,

I’m trying to compile Ruby using the native compiler xlc on AIX. Ruby  
seems to have compiled, but it falls over with a SEGV as soon as I run  
‘make test’, it falls over.

The reason I want to use the native compilers rather than gcc is to be  
sure that C++ name mangling is not an issue when I link Ruby’s libraries  
with my own code.

The output and my rbconfig.rb are attached below. Anyone have any  
ideas?

Cheers,  
Graza.

/home/build/ruby-1.9.1-p0/.ext/powerpc-aix5.3.0.0/enc/trans/transdb.so: [BUG] Segmentation fault ruby 1.9.1p0 (2009-01-30) [powerpc-aix5.3.0.0]
## – control frame ---------- c:0009 p:-570765290 s:0022 b:0022 l:000021 d:000021 TOP c:0008 p:---- s:0020 b:0020 l:000019 d:000019 CFUNC :require c:0007 p:0014 s:0016 b:0016 l:000007 d:000015 BLOCK internal:prelude:3 c:0006 p:---- s:0013 b:0013 l:000012 d:000012 FINISH c:0005 p:---- s:0011 b:0011 l:000010 d:000010 CFUNC :each c:0004 p:0014 s:0008 b:0008 l:000007 d:000007 TOP internal:prelude:1 c:0003 p:---- s:0006 b:0006 l:000005 d:000005 FINISH c:0002 p:-570713662 s:0004 b:0004 l:000003 d:000003 TOP c:0001 p:0000 s:0002 b:0002 l:000f28 d:000f28 TOP

– Ruby level backtrace  
information-----------------------------------------  
internal:prelude:3:in `require' <internal:prelude>:3:in `block in ’  
internal:prelude:1:in `each' <internal:prelude>:1:in `’

[NOTE]  
You may encounter a bug of Ruby interpreter. Bug reports are welcome.  
For details: [http://www.ruby-lang.org/bugreport.html](http://www.ruby-lang.org/bugreport.html)

make: \*\*\* [test-sample] IOT/Abort trap (core dumped)

# This file was created by mkconfig.rb when ruby was built. Any # changes made to this file will be lost the next time ruby is built.

module RbConfig  
RUBY\_VERSION == “1.9.1” or  
raise “ruby lib version (1.9.1) doesn’t match executable version  
(#{RUBY\_VERSION})”

TOPDIR =  
File.dirname( **FILE** ).chomp!(“/lib/ruby/1.9.1/powerpc-aix5.3.0.0”)  
DESTDIR = ‘’ unless defined? DESTDIR  
CONFIG = {}  
CONFIG[“DESTDIR”] = DESTDIR  
CONFIG[“INSTALL”] = ‘’  
CONFIG[“EXEEXT”] = “”  
CONFIG[“prefix”] = (TOPDIR || DESTDIR + “/ruby/install/path”)  
CONFIG[“ruby\_install\_name”] = “ruby”  
CONFIG[“RUBY\_INSTALL\_NAME”] = “ruby”  
CONFIG[“RUBY\_SO\_NAME”] = “ruby”  
CONFIG[“BUILTIN\_TRANSSRCS”] = " newline.c"  
CONFIG[“MANTYPE”] = “man”  
CONFIG[“NROFF”] = “/usr/bin/nroff”  
CONFIG[“vendorhdrdir”] = “$(rubyhdrdir)/vendor\_ruby”  
CONFIG[“sitehdrdir”] = “$(rubyhdrdir)/site\_ruby”  
CONFIG[“rubyhdrdir”] =  
“$(includedir)/$(RUBY\_INSTALL\_NAME)-$(ruby\_version)”  
CONFIG[“configure\_args”] = " ‘–prefix=/ruby/install/path’  
‘CC=/usr/vac/bin/xlc’ ‘CFLAGS=-O3 -q64 -qcpluscmt -qlanglvl=extended  
-qcheck=nullptr -Wl,-brtl -I/nfs/home/gagnew/aix/app/include’  
‘LDFLAGS=-L/nfs/home/gagnew/aix/app/lib’ ‘CXX=/usr/vac/bin/xlc’"  
CONFIG[“vendordir”] = “$(libdir)/$(RUBY\_INSTALL\_NAME)/vendor\_ruby”  
CONFIG[“sitedir”] = “$(libdir)/$(RUBY\_INSTALL\_NAME)/site\_ruby”  
CONFIG[“ruby\_version”] = “1.9.1”  
CONFIG[“sitearch”] = “powerpc-aix5.3.0.0”  
CONFIG[“arch”] = “powerpc-aix5.3.0.0”  
CONFIG[“MAKEFILES”] = “Makefile”  
CONFIG[“THREAD\_MODEL”] = “pthread”  
CONFIG[“EXPORT\_PREFIX”] = “”  
CONFIG[“COMMON\_HEADERS”] = “”  
CONFIG[“COMMON\_MACROS”] = “”  
CONFIG[“COMMON\_LIBS”] = “”  
CONFIG[“MAINLIBS”] = “”  
CONFIG[“ENABLE\_SHARED”] = “no”  
CONFIG[“DLDLIBS”] = " -lc"  
CONFIG[“SOLIBS”] = “”  
CONFIG[“LIBRUBYARG\_SHARED”] = “-l$(RUBY\_SO\_NAME)”  
CONFIG[“LIBRUBYARG\_STATIC”] = “-l$(RUBY\_SO\_NAME)-static”  
CONFIG[“LIBRUBYARG”] = “$(LIBRUBYARG\_STATIC)”  
CONFIG[“LIBRUBY”] = “$(LIBRUBY\_A)”  
CONFIG[“LIBRUBY\_ALIASES”] = “lib$(RUBY\_SO\_NAME).so”  
CONFIG[“LIBRUBY\_SO”] =  
“lib$(RUBY\_SO\_NAME).so.$(MAJOR).$(MINOR).$(TEENY)”  
CONFIG[“LIBRUBY\_A”] = “lib$(RUBY\_SO\_NAME)-static.a”  
CONFIG[“RUBYW\_INSTALL\_NAME”] = “”  
CONFIG[“rubyw\_install\_name”] = “”  
CONFIG[“LIBRUBY\_DLDFLAGS”] = “-eInit\_$(TARGET)”  
CONFIG[“LIBRUBY\_LDSHARED”] = “$(CC) -G”  
CONFIG[“warnflags”] = “”  
CONFIG[“debugflags”] = “-g”  
CONFIG[“optflags”] = “”  
CONFIG[“cflags”] = “$(optflags) $(debugflags) $(warnflags)”  
CONFIG[“cppflags”] = “”  
CONFIG[“RDOCTARGET”] = “install-doc”  
CONFIG[“ARCHFILE”] = “ruby.imp”  
CONFIG[“EXTOUT”] = “.ext”  
CONFIG[“PREP”] = “miniruby$(EXEEXT)”  
CONFIG[“setup”] = “Setup”  
CONFIG[“EXTSTATIC”] = “”  
CONFIG[“STRIP”] = “strip”  
CONFIG[“TRY\_LINK”] = “$(CC) $(LDFLAGS) -oconftest $(INCFLAGS)  
-I$(hdrdir) $(CPPFLAGS) $(CFLAGS) $(src) $(LIBPATH) $(LOCAL\_LIBS)  
$(LIBS)”  
CONFIG[“LIBPATHENV”] = “SHLIB\_PATH”  
CONFIG[“RPATHFLAG”] = " -blibpath:%1$-s"  
CONFIG[“LIBPATHFLAG”] = " -L%1$-s"  
CONFIG[“LINK\_SO”] = “”  
CONFIG[“LIBEXT”] = “a”  
CONFIG[“DLEXT2”] = “”  
CONFIG[“DLEXT”] = “so”  
CONFIG[“LDSHAREDXX”] = “$(CXX) -G”  
CONFIG[“LDSHARED”] = “$(CC) -G”  
CONFIG[“CCDLFLAGS”] = “”  
CONFIG[“STATIC”] = “”  
CONFIG[“ARCH\_FLAG”] = “”  
CONFIG[“DLDFLAGS”] = “-eInit\_$(TARGET)”  
CONFIG[“ALLOCA”] = “”  
CONFIG[“RMALL”] = “rm -fr”  
CONFIG[“RMDIRS”] = “$(top\_srcdir)/tool/rmdirs”  
CONFIG[“MAKEDIRS”] = “mkdir -p”  
CONFIG[“CP”] = “cp”  
CONFIG[“RM”] = “rm -f”  
CONFIG[“INSTALL\_DATA”] = “$(INSTALL) -m 644”  
CONFIG[“INSTALL\_SCRIPT”] = “$(INSTALL)”  
CONFIG[“INSTALL\_PROGRAM”] = “$(INSTALL)”  
CONFIG[“SET\_MAKE”] = “”  
CONFIG[“LN\_S”] = “ln -s”  
CONFIG[“DLLWRAP”] = “”  
CONFIG[“WINDRES”] = “”  
CONFIG[“NM”] = “nm”  
CONFIG[“OBJCOPY”] = “”  
CONFIG[“OBJDUMP”] = “”  
CONFIG[“ASFLAGS”] = “”  
CONFIG[“AS”] = “as”  
CONFIG[“AR”] = “ar”  
CONFIG[“RANLIB”] = “ranlib”  
CONFIG[“COUTFLAG”] = “-o "  
CONFIG[“OUTFLAG”] = “-o "  
CONFIG[“CPPOUTFILE”] = “\> conftest.i”  
CONFIG[“GNU\_LD”] = “no”  
CONFIG[“EGREP”] = “/usr/bin/grep -E”  
CONFIG[“GREP”] = “/usr/bin/grep”  
CONFIG[“CPP”] = “/usr/vac/bin/xlc -E”  
CONFIG[“CXXFLAGS”] = " -g”  
CONFIG[“CXX”] = “/usr/vac/bin/xlc”  
CONFIG[“OBJEXT”] = “o”  
CONFIG[“CPPFLAGS”] = " $(DEFS) $(cppflags)”  
CONFIG[“LDFLAGS”] = “-L. -L/home/build/aix/app/lib”  
CONFIG[“CFLAGS”] = “-O3 -q64 -qcpluscmt -qlanglvl=extended  
-qcheck=nullptr -Wl,-brtl -I/nfs/home/gagnew/aix/app/include -g”  
CONFIG[“CC”] = “/usr/vac/bin/xlc”  
CONFIG[“target\_os”] = “aix5.3.0.0”  
CONFIG[“target\_vendor”] = “ibm”  
CONFIG[“target\_cpu”] = “powerpc”  
CONFIG[“target”] = “powerpc-ibm-aix5.3.0.0”  
CONFIG[“host\_os”] = “aix5.3.0.0”  
CONFIG[“host\_vendor”] = “ibm”  
CONFIG[“host\_cpu”] = “powerpc”  
CONFIG[“host”] = “powerpc-ibm-aix5.3.0.0”  
CONFIG[“build\_os”] = “aix5.3.0.0”  
CONFIG[“build\_vendor”] = “ibm”  
CONFIG[“build\_cpu”] = “powerpc”  
CONFIG[“build”] = “powerpc-ibm-aix5.3.0.0”  
CONFIG[“TEENY”] = “1”  
CONFIG[“MINOR”] = “9”  
CONFIG[“MAJOR”] = “1”  
CONFIG[“BASERUBY”] = “ruby”  
CONFIG[“target\_alias”] = “”  
CONFIG[“host\_alias”] = “”  
CONFIG[“build\_alias”] = “”  
CONFIG[“LIBS”] = "-lpthread -lrt -ldl -lcrypt -lm "  
CONFIG[“ECHO\_T”] = “”  
CONFIG[“ECHO\_N”] = “”  
CONFIG[“ECHO\_C”] = “\\c”  
CONFIG[“DEFS”] = “”  
CONFIG[“mandir”] = “$(datarootdir)/man”  
CONFIG[“localedir”] = “$(datarootdir)/locale”  
CONFIG[“libdir”] = “$(exec\_prefix)/lib”  
CONFIG[“psdir”] = “$(docdir)”  
CONFIG[“pdfdir”] = “$(docdir)”  
CONFIG[“dvidir”] = “$(docdir)”  
CONFIG[“htmldir”] = “$(docdir)”  
CONFIG[“infodir”] = “$(datarootdir)/info”  
CONFIG[“docdir”] = “$(datarootdir)/doc/$(PACKAGE)”  
CONFIG[“oldincludedir”] = “/usr/include”  
CONFIG[“includedir”] = “$(prefix)/include”  
CONFIG[“localstatedir”] = “$(prefix)/var”  
CONFIG[“sharedstatedir”] = “$(prefix)/com”  
CONFIG[“sysconfdir”] = “$(prefix)/etc”  
CONFIG[“datadir”] = “$(datarootdir)”  
CONFIG[“datarootdir”] = “$(prefix)/share”  
CONFIG[“libexecdir”] = “$(exec\_prefix)/libexec”  
CONFIG[“sbindir”] = “$(exec\_prefix)/sbin”  
CONFIG[“bindir”] = “$(exec\_prefix)/bin”  
CONFIG[“exec\_prefix”] = “$(prefix)”  
CONFIG[“PACKAGE\_BUGREPORT”] = “”  
CONFIG[“PACKAGE\_STRING”] = “”  
CONFIG[“PACKAGE\_VERSION”] = “”  
CONFIG[“PACKAGE\_TARNAME”] = “”  
CONFIG[“PACKAGE\_NAME”] = “”  
CONFIG[“PATH\_SEPARATOR”] = “:”  
CONFIG[“SHELL”] = “/bin/sh”  
CONFIG[“rubylibdir”] =  
“$(libdir)/$(ruby\_install\_name)/$(ruby\_version)”  
CONFIG[“archdir”] = “$(rubylibdir)/$(arch)”  
CONFIG[“sitelibdir”] = “$(sitedir)/$(ruby\_version)”  
CONFIG[“sitearchdir”] = “$(sitelibdir)/$(sitearch)”  
CONFIG[“vendorlibdir”] = “$(vendordir)/$(ruby\_version)”  
CONFIG[“vendorarchdir”] = “$(vendorlibdir)/$(sitearch)”  
CONFIG[“topdir”] = File.dirname( **FILE** )  
MAKEFILE\_CONFIG = {}  
CONFIG.each{|k,v| MAKEFILE\_CONFIG[k] = v.dup}  
def RbConfig::expand(val, config = CONFIG)  
val.gsub!(/$$|$(([^()]+))|${([^{}]+)}/) do  
var = $&  
if !(v = $1 || $2)  
‘$’  
elsif key = config[v = v[/\A[^:]+(?=(?::(._?)=(._))?\z)/]]  
pat, sub = $1, $2  
config[v] = false  
RbConfig::expand(key, config)  
config[v] = key  
key = key.gsub(/#{Regexp.quote(pat)}(?=\s|\z)/n) {sub} if pat  
key  
else  
var  
end  
end  
val  
end  
CONFIG.each\_value do |val|  
RbConfig::expand(val)  
end  
end  
Config = RbConfig # compatibility for ruby-1.8.4 and older.  
CROSS\_COMPILING = nil unless defined? CROSS\_COMPILING

---

<div class="post-metadata">

**Author:** ![graza](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/838e76/32.png) [@graza](https://www.ruby-forum.com/u/graza)\
**Post date:** [March 18, 2009, 1:13pm UTC](https://www.ruby-forum.com/t/compiling-1-9-1p0-on-aix-5-3-using-xlc/161997/2 "2009-03-18T13:13:20Z")

</div>

Not sure if it’s the root-cause at this stage, but I’ve found that core  
dump is happening when trying to load enc/trans/transdb.so. Having  
looked closer at warnings etc when rebuilding, I saw that the linker was  
complaining that the Init\_ symbol didn’t exist. The search for this  
symbol is actually as a result of this:

> CONFIG[“DLDFLAGS”] = “-eInit\_$(TARGET)”

The setting of $TARGET is something that used to happen in 1.8 as part  
of building the ext directory, but it not happening when building the  
contents of the enc directory in 1.9.1.

---

<div class="post-metadata">

**Author:** ![graza](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/838e76/32.png) [@graza](https://www.ruby-forum.com/u/graza)\
**Post date:** [March 19, 2009, 4:13pm UTC](https://www.ruby-forum.com/t/compiling-1-9-1p0-on-aix-5-3-using-xlc/161997/3 "2009-03-19T16:13:41Z")

</div>

So, I’ve gotten over this hurdle by modifying the enc.mk file to use the  
following value for dldflags:

> dldflags = -eInit\_$(basename $(notdir $@))

The -e option to th compiler sets the entry point of the shared library  
in AIX. This is needed because in dln.c, the load() function is  
expected to return a pointer to this function. But as I trace through  
this, the encdb.so still wasn’t loading due to unresolved symbols.

I’ve further modified enc.mk to link in encoding.o to resolve these  
missing symbols. So now encdb.so loads. Now I’m getting a problem with  
miniruby getting into an infinite loop. For some reason it’s spinning  
on line 384 in st.c.

unpack\_entries(table = (nil), 0x110296f70, 0x0), line 384 in "st.c" dmyencoding.enc\_register\_at(index = 150994943, name = "\360", encoding = 0x0fffffffffffdb30), line 204 in "encoding.c" dmyencoding.enc\_register(name = "", encoding = 0x09001000a067c4d0), line 219 in "encoding.c" dmyencoding.rb\_encdb\_declare(name = ""), line 255 in "encoding.c" Init\_encdb(), line 1 in "encdb.h" unnamed block in dln\_load(file = "c\343"), line 1348 in "dln.c" dln\_load(file = "c\343"), line 1348 in "dln.c" load\_ext(path = 4295785724), line 532 in "load.c" rb\_vm\_call\_cfunc(recv = 1152921504606838400, func = 0x00000001101cc5d0, arg = 4295439756, blockptr = (nil), filename = 1152921504606838400), line 1371 in "vm.c" unnamed block in rb\_require\_safe(fname = 4564958760, safe = 0), line 567 in "load.c" rb\_require\_safe(fname = 4564958760, safe = 0), line 567 in "load.c" dmyencoding.require\_enc(enclib = 0), line 452 in "encoding.c" rb\_protect(proc = 0x000000011002c648, data = 4564958760, state = (nil)), line 647 in "eval.c" dmyencoding.load\_encoding(name = (invalid char ptr (0xbadc0ffee0ddf00d))), line 474 in "encoding.c" dmyencoding.rb\_enc\_find\_index(name = "^I"), line 514 in "encoding.c" process\_options(arg = 12), line 1280 in "ruby.c" rb\_vm\_call\_cfunc(recv = 4564961360, func = 0x000000011002e9c8, arg = 0, blockptr = 0x0000000100196288, filename = 1152921504606842768), line 1371 in "vm.c" ruby\_process\_options(argc = 1767859311, argv = 0x74002e646f5f736f), line 1805 in "ruby.c" unnamed block in ruby\_options(argc = 12, argv = 0x0ffffffffffff470), line 88 in "eval.c" ruby\_options(argc = 12, argv = 0x0ffffffffffff470), line 88 in "eval.c" unnamed block in main(argc = 12, argv = 0x0ffffffffffff470), line 34 in "main.c" main(argc = 12, argv = 0x0ffffffffffff470), line 34 in "main.c"

Anyone with any clues here? I’ve also tried linking with encdb.so with  
dmyencoding.o since dmyenoding.c just does a #define and then a #include  
of encoding.c, but it doesn’t make any difference.

I’m now completely stuck.

---

<div class="post-metadata">

**Author:** ![graza](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/838e76/32.png) [@graza](https://www.ruby-forum.com/u/graza)\
**Post date:** [March 19, 2009, 8:43pm UTC](https://www.ruby-forum.com/t/compiling-1-9-1p0-on-aix-5-3-using-xlc/161997/4 "2009-03-19T20:43:56Z")

</div>

Graham A. wrote:

> missing symbols. So now encdb.so loads. Now I’m getting a problem with  
> miniruby getting into an infinite loop. For some reason it’s spinning  
> on line 384 in st.c.  
> […]  
> I’m now completely stuck.

I have a similar issue when compiling trunk with llvm (version does not  
seem to matter). miniruby spins and is only killable with -9. I  
submitted a but report for this, answer was that only gcc is supported.

---

<div class="post-metadata">

**Author:** ![graza](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/838e76/32.png) [@graza](https://www.ruby-forum.com/u/graza)\
**Post date:** [March 20, 2009, 11:51am UTC](https://www.ruby-forum.com/t/compiling-1-9-1p0-on-aix-5-3-using-xlc/161997/5 "2009-03-20T11:51:16Z")

</div>

Hi Nakada-san,

I’ve tried to register on redmine to be able to log these things as  
bugs, but for some reason it won’t let me in. The forgot password page  
accepts my email address, so it would seem that I’m registered, but I  
don’t then receive an email indicating a new password or how to get back  
in.

The patch you provided works fine. Thanks for that.

The missing symbols reported when loading encdb.so were rb\_encdb\_declare  
and rb\_encdb\_alias although there were other errors. The missing  
symbols and other errors were found by adding the follwoing lines to  
aix\_loaderror in dln.c:

> {  
> int pid, st;  
> if (pid = fork()) {  
> waitpid(pid, &st, 0);  
> }  
> else {  
> message[0] = “execerror”;  
> message[1] = pathname;  
> execvp("/usr/sbin/execerror",message);  
> }  
> }

This produces better output than the original code in the aix\_loaderror  
function:

> exec(): 0509-036 Cannot load program /nfs/home/gagnew/aix/ruby-1.9.1-p0/.ext/powerpc-aix5.3.0.0/enc/encdb.so because of the following errors:  
> 0509-161 There is not enough memory for the process.  
> rtld: 0712-001 Symbol rb\_encdb\_declare/nfs/home/gagnew/aix/ruby-1.9.1-p0/.ext/powerpc-aix5.3.0.0/enc/encdb.so was referenced  
> from module /nfs/home/gagnew/aix/ruby-1.9.1-p0/.ext/powerpc-aix5.3.0.0/enc/encdb.so(), but a runtime definition  
> of the symbol was not found.  
> rtld: 0712-001 Symbol rb\_encdb\_alias was referenced  
> from module /nfs/home/gagnew/aix/ruby-1.9.1-p0/.ext/powerpc-aix5.3.0.0/enc/encdb.so(), but a runtime definition  
> of the symbol was not found.  
> rtld: 0712-002 fatal error: exiting.  
> 0509-021 Additional errors occurred but are not reported.

I’ve noticed that the prelude code ignores the errors reported when  
loading encdb.so. There are other symbols missing when loading  
euc\_jp.so:

> exec(): 0509-036 Cannot load program /nfs/home/gagnew/aix/ruby-1.9.1-p0/.ext/powerpc-aix5.3.0.0/enc/euc\_jp.so because of the following errors:  
> rtld: 0712-001 Symbol rb\_enc\_register was referenced  
> from module /nfs/home/gagnew/aix/ruby-1.9.1-p0/.ext/powerpc-aix5.3.0.0/enc/euc\_jp.so(), but a runtime definition  
> of the symbol was not found.  
> rtld: 0712-002 fatal error: exiting.

Cheers,  
Gra.

---

<div class="post-metadata">

**Author:** ![graza](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/838e76/32.png) [@graza](https://www.ruby-forum.com/u/graza)\
**Post date:** [March 20, 2009, 3:43am UTC](https://www.ruby-forum.com/t/compiling-1-9-1p0-on-aix-5-3-using-xlc/161997/6 "2009-03-20T03:43:09Z")

</div>

Hi,

At Thu, 5 Mar 2009 00:54:05 +0900,  
Graham A. wrote in [ruby-talk:330286]:

> I’m trying to compile Ruby using the native compiler xlc on AIX. Ruby  
> seems to have compiled, but it falls over with a SEGV as soon as I run  
> ‘make test’, it falls over.

Why not register to [http://redmine.ruby-lang.org](http://redmine.ruby-lang.org) ?

At Fri, 20 Mar 2009 00:11:00 +0900,  
Graham A. wrote in [ruby-talk:331586]:

> So, I’ve gotten over this hurdle by modifying the enc.mk file to use the  
> following value for dldflags:
> 
> > dldflags = -eInit\_$(basename $(notdir $@))

Does the following patch work?

> I’ve further modified enc.mk to link in encoding.o to resolve these  
> missing symbols. So now encdb.so loads. Now I’m getting a problem with  
> miniruby getting into an infinite loop. For some reason it’s spinning  
> on line 384 in st.c.

What are missing symbols?

# Index: enc/depend

— enc/depend (revision 23012)  
+++ enc/depend (working copy)  
@@ -1,2 +1,4 @@  
+% CONFIG[“DLDFLAGS”].sub!(/(\A|\s)(-\S+(?:\s\*\w\*)?$(TARGET)\S\*)/,  
‘\1’)  
+% dldflags = $2  
% enable\_shared = CONFIG[‘ENABLE\_SHARED’] == ‘yes’  
% deffile = (true if /$(DEFFILE)/ =~ CONFIG[“LINK\_SO”])  
@@ -104,10 +106,15 @@ $(TRANSOBJS): ruby.h intern.h config.h d  
% df = (“enc/#{e}.def” if deffile)  
$(ENCSODIR)/\<%=e%\>.$(DLEXT): \<%=obj%\>  
+% cmd = link\_so.sub(/$(OBJS)/) {obj}  
+% base = File.basename(e)  
+% cmd.sub!(/(?=$(DLDFLAGS))/) {dldflags.sub(/$(TARGET)/) {base}

- " "} if dldflags  
% if df  
echo\> \<%=df%\> EXPORTS

- echo\>\> \<%=df%\> \<%=EXPORT\_PREFIX%\>Init\_\<%=File.basename(e)%\>

- echo\>\> \<%=df%\> \<%=EXPORT\_PREFIX%\>Init\_\<%=base%\>  
+% cmd.sub!(/$(DEFFILE)/) {df}  
+% cmd.gsub!(/-(?:implib|pdb):/) {|s|“#{s}enc/#{e.sub(/[^/]+\z/,  
‘’)}”}  
% end  
@$(MAKEDIRS) “$(@D)”

- \<%=link\_so.sub(/$(OBJS)/) {obj}.sub(/$(DEFFILE)/)  
{df}.gsub(/-(?:implib|pdb):/) {|s|“#{s}enc/#{e.sub(/[^/]+\z/, ‘’)}”}%\>

- \<%=cmd%\>

% end

---

<div class="post-metadata">

**Author:** ![graza](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/838e76/32.png) [@graza](https://www.ruby-forum.com/u/graza)\
**Post date:** [March 30, 2009, 3:44pm UTC](https://www.ruby-forum.com/t/compiling-1-9-1p0-on-aix-5-3-using-xlc/161997/7 "2009-03-30T15:44:14Z")

</div>

Hi Kanemoto-san,

Thanks for the patch. That’s resolved the problem.

I was wondering whether the common.mk should run nm over all the objects  
in $(OBJS) rather than just $(COMMONOBJS) and encoding.o? This seems a  
more generic solution to me.

Cheers,  
Gra.

---

<div class="post-metadata">

**Author:** ![graza](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/838e76/32.png) [@graza](https://www.ruby-forum.com/u/graza)\
**Post date:** [March 27, 2009, 5:48pm UTC](https://www.ruby-forum.com/t/compiling-1-9-1p0-on-aix-5-3-using-xlc/161997/8 "2009-03-27T17:48:37Z")

</div>

Hi Graham,

> The missing symbols reported when loading encdb.so were rb\_encdb\_declare  
> and rb\_encdb\_alias although there were other errors.  
> It seems that some symbols are not exported.
