News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

thread safe errors ???

Started by DarkWolf, June 26, 2009, 09:33:22 PM

Previous topic - Next topic

DarkWolf

The program is just an hello world app but I tried to compile it with the thread safe version of stdlib.a

It is just a call to stdout.put, I know the docs say the stdout threads have to be managed by me but it is only one call and I don't make any other use of stdout.

Errors, HLA source and GAS is in the zipped text file.

This wasn't really a serious attempt but I was curious if even an hello world sort of app needed some changes for "thread safe".

[attachment deleted by admin]
--
Where's there's smoke, There are mirrors.
Give me Free as in Freedom not Speech or Beer.
Thank You and Welcome to the Internet.

Evenbit

Looks like just a simple misunderstanding of how to use the compiler switches.

"-level=h" does not have any meaning when you are linking an object file.  It is also not needed because it is the default.

Likewise, "-xg" has no meaning.  It is also default on Linux, so is not needed.

It is probably wiser to compile & link in one step when using the thread-safe library.  Therefore, change this line...

hla  -v -thread -level=h  -xg -l'm elf_i386'  -x:bin/project src/project.o >> log/build.log

...to this:

hla  -v -thread -l'm elf_i386'  -x:bin/project src/project >> log/build.log

Nathan.

DarkWolf

Quote from: Evenbit
Looks like just a simple misunderstanding of how to use the compiler switches.

"-level=h" does not have any meaning when you are linking an object file.  It is also not needed because it is the default.

Macro expansion from a makefile, I set parameters for compiling in a macro and just use that. All my makefiles are set for "-v -level=h" and I added "-thread" to test.
Yes I realize -level=h is by default but it doesn't hurt anything and default behavior or my needs could change in the future.

Quote from: Evenbit
Likewise, "-xg" has no meaning.  It is also default on Linux, so is not needed.

Same macro expansion explanation as above (also same reason --32 gets repeated twice below I didn't know hla already passes that parameter to as)

Quote from: Evenbit
hla  -v -thread -level=h  -xg -l'm elf_i386'  -x:bin/project src/project.o >> log/build.log
From verbose output of non-working line:

Assembling "src/project.asm" to "src/project.o" via [as --32 -o src/project.o --32 -march=generic32   "src/project.asm"]
Linking via [ld   -m elf_i386   -o "bin/project"   "src/project.o" "/media/data/Programming/asm/hlalib/hlalib_safe.a"]
Error returned by ld = 256


Quote from: Evenbit
hla  -v -thread -l'm elf_i386'  -x:bin/project src/project >> log/build.log
From verbose output of working line:

Assembling "src/project.asm" to "src/project.o" via [as --32 -o src/project.o --32 -march=generic32   "src/project.asm"]
Assembling "src/project.asm" to "src/project.o" via [as --32 -o src/project.o   "src/project.asm"]
Linking via [ld   -m elf_i386   -o "bin/project" -lpthread -lc -I /lib/ld-linux.so.2   "src/project.o" "/media/data/Programming/asm/hlalib/hlalib_safe.a"]


(Don't know why but it compiled *.asm to *.o twice with different options[but all my macros are the same ??])
(First one should be from my makefile the second should be from compiling and linking in same step)

From verbose output of non-working line:

Assembling "src/project.asm" to "src/project.o" via [as --32 -o src/project.o --32 -march=generic32   "src/project.asm"]
Linking via [ld   -m elf_i386   -o "bin/project"   "src/project.o" "/media/data/Programming/asm/hlalib/hlalib_safe.a"]
Error returned by ld = 256


Ignore the fact that source gets compiled twice (that's my makefile depends I'll fix later; I can get to compile with same options so no showstopper and it works). My question is why does ld get passed two different sets of options. Under separate compile/link it is not passed the threaded options (but I pass the -thread parm) and in single compile/link it does (-thread is also passed) ?

Warning possibly confusing macro chain from makefile:

POPT=-v -thread -level=h
PCO=$(POPT) -cg -o:elf         # <---  -linux not specified because it is confused for passing linker options (or I would use it)
PC32=$(PCO) -a-32 -amarch=generic32
PLO=$(POPT) -xg                    # <---  ditto
PL32=$(PLO) -l'm elf_i386'


POPT (where -thread is passed) is used for both linking and compiling so I don't understand how under separate compiling it doesn't work. HLA's -? parmater is nice in that it outlines source, compile and link options together in there own sections but -thread is listed in the first section so I use it as a base parameter for all operations. Is that wrong ??

And yes I know I am specifying some parms that are default.
--
Where's there's smoke, There are mirrors.
Give me Free as in Freedom not Speech or Beer.
Thank You and Welcome to the Internet.