Forum OpenACS Q&A: Do NOT compile nsxml with -O !

Collapse
Posted by Andrew Piskorski on
Short version: Do not compile nsxml with GCCOPTIMIZE set to anything other than "-g". -O, -O1, -O2 all seem to cause it to break! (Anybody know why?)

Long version:

I'm trying to install OpenACS 4.6 on Debian 3.0, using Oracle. Initially, I compiled all of AOLserver 3.3+ad13 with "-O2 -g". I'm using the latest nsxml from SourceForge (nsxml.c rev. 1.12 2002/07/23), and libxml2 ver. 2.4.19 (the GNOME XML library).

Debian keeps it's libxml2 headers and libraries in a different place, so I had to tweak the nsxml Makefile slightly:

#XML_HEADERS = /usr/local/include
#XML_LIBS = /usr/local/lib
# For Debian:
XML_HEADERS = /usr/include/libxml2
XML_LIBS = /usr/lib

Everything goes smoothly through the "Done installing the OpenACS kernel data model" message on the web page. However, immediately after that, the install stops, with this error in the server log:

[09/Dec/2002:18:14:19][23784.4101][-conn0-] Error: Error sourcing /web/test-46-ora/packages/acs-bootstrap-installer/installer/install-data-model.tcl: 
invalid token "n2" 
    while executing 
"GetHandle node $token node" 
    (procedure "dom::node" line 5) 
    invoked from within 
"dom::node cget $element -nodeName" 
    (procedure "apm_required_attribute_value" line 4) 
    invoked from within 
"apm_required_attribute_value $package key" 
    (procedure "apm_read_package_info_file" line 50) 
    invoked from within 
"apm_read_package_info_file $spec_file_path" 
    (procedure "apm_package_install" line 4) 
    invoked from within 
"apm_package_install -callback apm_ns_write_callback "[file join [acs_root_dir] packages acs-kernel acs-kernel.info]"" 
    invoked from within 
"apm_version_enable -callback apm_ns_write_callback [apm_package_install -callback apm_ns_write_callback "[file join [acs_root_dir] packages acs-kernel..." 
    (file "/web/test-46-ora/packages/acs-bootstrap-installer/installer/install-data-model.tcl" line 63) 
    invoked from within 
"source $__file " 

That DOM stuff is probably using nsxml, so my guess is I have some sort of problem with my nsxml. But I don't really know. Luckily, even though I didn't think it would matter I tried re-compiling nsxml with just plain "-g", no -O at all. And it worked!

I don't know why though. Anyone have ideas?

Also, would it be bad to compile nsxml with "-g" but the rest of AOLserver with "-O1 -g"? Is it bad to mix loadable modules compiled with different optimization settings? How do you folks compile your AOLservers? Does anyone use any optimization at all, or are you all just using plain "-g"?

I don't think I care about optimizing the AOLserver C code, but I would like to try compiling the Tcl interpreter with optimization, as that part I've managed to make crawl in the past. Any thoughts on this?

Collapse
Posted by Jon Griffin on
What version of gcc is debian using? I compile all my code -O2 and have had no problems.

I am using gcc 2.95-3 20010315.

Collapse
Posted by Andrew Piskorski on
Ah, I forgot to say that.  gcc -v reports "gcc version 2.95.4 20011002 (Debian prerelease)".
Collapse
Posted by Andrew Piskorski on
Debian also installs gcc 3.0 as an alternate compiler, but I haven't tried that.
Collapse
Posted by Roberto Mello on
Well, I'm not sure about GCC especifics, but adding debugging symbols (-g) should disable any optimization.

That's what I did in the compiler I wrote, but perhaps gcc is smarter.

-Roberto

Collapse
Posted by Andrew Piskorski on
Roberto, no, gcc specifically allows debugging symbols (-g) and optimization (-O) at the same time. How useful that that is in practice, I'm not sure, but it is supposed to work.
Collapse
Posted by Roberto Mello on
Interesting,

They do say that your program will have unpredictable results when being debugged though. So if you're not planning to debug it, it should be safe to just not put any optimizations in.

I'm making an educated guess here, but it should also be okay to compile AOLserver with -Ox and ns_xml without.

-Roberto

Collapse
Posted by Jeff Davis on
It's fine to mix different optimization levels and if that makes the problem go away thats nice. My experience though is that if behavior changes in a C program based on different optimization flags is almost always due to a memory bug; maybe someone can try running purify on aolserver/nsxml?

Anyway, I do -g -O2 on everything and have not had any problems either. As for debugging things compiled -g -O2, usually it's pretty easy to do. Your life is easier when you have debugable executables and with gcc allowing optimization together with debug symbols there aren't too many reasons not to always have the symbols.

Collapse
Posted by Andrew Piskorski on
FYI, the Debian 3.0 r1 update updated gcc (from 2.95.4-7 to 2.95.4-11woody1) and various other things, but it made no difference for this problem. If I compile nsxml with -O it still doesn't work right. With the bad nsxml (compiled with "-g -O2" in this case), as soon as I go the the OpenACS front page, nsxml fails to get a query out the xql file, and I get this error:

Error: SQL(): ora8.c:3682:ora_tcl_command: error in `OCIStmtPrepare ()': ORA-24373: invalid length specified for statement

Compile nsxml with just -g on this box, and everything still works fine.