Opened 19 years ago
Closed 18 years ago
#39 closed enhancement (fixed)
dllar.cmd enhancements
Reported by: | Yuri Dario | Owned by: | bird |
---|---|---|---|
Priority: | normal | Milestone: | libc-0.6.2 |
Component: | emx | Version: | 0.6 |
Severity: | normal | Keywords: | |
Cc: |
Description
This patch allows dllar.cmd to produce also omf import libraries and use a predefined .def file instead of writing a new one. Unfortunately I lost the changes for dealing with .lib static libraries.
--- E:\dev\gcc06\bin\dllar.cmd Sun Jan 22 23:27:24 2006 +++ dllar.cmd Wed Jan 4 11:10:32 2006 @@ -62,11 +62,10 @@ parse arg cmdLine; cmdLine = cmdLine||" "||value('DLLAR_CMDLINE',,'OS2ENVIRONMENT'); outFile = ''; - useDefFile = ''; inputFiles.0 = 0; description = ''; CC = 'gcc.exe'; - CFLAGS = '-Zcrtdll'; + CFLAGS = '-s -Zcrtdll'; EXTRA_CFLAGS = ''; EXPORT_BY_ORDINALS = 0; exclude_symbols = ''; @@ -86,8 +85,6 @@ i = i + 1; outFile = word(cmdLine, i); end; - when abbrev('def', substr(tmp, 2), 3) then - useDefFile = GetLongArg(); when abbrev('description', substr(tmp, 2), 1) then description = GetLongArg(); when abbrev('flags', substr(tmp, 2), 1) then @@ -103,7 +100,7 @@ when abbrev('libflags', substr(tmp, 2), 4) then library_flags = library_flags||GetLongArg()' '; when abbrev('nocrtdll', substr(tmp, 2), 5) then - CFLAGS = ''; + CFLAGS = '-s'; when abbrev('nolxlite', substr(tmp, 2), 5) then flag_USE_LXLITE = 0; otherwise @@ -210,13 +207,10 @@ defFile = outFile'.def'; dllFile = outFile'.dll'; arcFile = outFile'.a'; - arcFileOmf = outFile'.lib'; if (do_backup & stream(arcFile, 'C', 'query exists') \= '') then call doCommand('ren 'arcFile' 'outFile'_s.a'); -if useDefFile = '' then -do /* * Extract public symbols from all the object files. */ @@ -262,13 +256,6 @@ call SysFileDelete(tmpdefFile); drop line ordinal tmpdefFile; /* try prevent running out of memory... */ -end -else do - - defFile = useDefFile; - -end - if 0 then do @@ -305,7 +292,6 @@ end call doCommand('emximp -o 'arcFile defFile); - call doCommand('emximp -o 'arcFileOmf defFile); if (flag_USE_LXLITE) then do add_flags = ''; @@ -327,13 +313,12 @@ say 'Usage: dllar [-o[utput] output_file] [-d[escription] "dll descrption"]' say ' [-cc "CC"] [-f[lags] "CFLAGS"] [-ord[inals]] -ex[clude] "symbol(s)"' say ' [-libf[lags] "{INIT|TERM}{GLOBAL|INSTANCE}"] [-nocrt[dll]]' - say ' [-nolxlite] [-def def_file]"' say ' [*.o] [*.a]' say '*> "output_file" should have no extension.' say ' If it has the .o, .a or .dll extension, it is automatically removed.' say ' The import library name is derived from this and is set to "name".a.' say '*> "cc" is used to use another GCC executable. (default: gcc.exe)' - say '*> "flags" should be any set of valid GCC flags. (default: -Zcrtdll)' + say '*> "flags" should be any set of valid GCC flags. (default: -s -Zcrtdll)' say ' These flags will be put at the start of GCC command line.' say '*> -ord[inals] tells dllar to export entries by ordinals. Be careful.' say '*> -ex[clude] defines symbols which will not be exported. You can define' @@ -344,8 +329,6 @@ say ' TERMGLOBAL/TERMINSTANCE flags to the dynamically-linked library.' say '*> -nocrtdll switch will disable linking the library against emx''s' say ' C runtime DLLs.' - say '*> -nolxlite does not compress executable' - say '*> -def def_file do not generate .def file, use def_file instead.' say '*> All other switches (for example -L./ or -lmylib) will be passed' say ' unchanged to GCC at the end of command line.' say '*> If you create a DLL from a library and you do not specify -o,'
Change History (8)
comment:1 by , 19 years ago
comment:2 by , 19 years ago
Type: | defect → enhancement |
---|
comment:4 by , 19 years ago
Milestone: | libc-0.6.1 → libc-0.6.2 |
---|
comment:5 by , 19 years ago
This new patch allows building from OMF libraries and adds a new flag for setting DATA segment attributes. Includes previous changes.
BTW no flag is required for -s or -g, since all unknown flags are added to gcc link stage command line.
Index: dllar.cmd =================================================================== --- dllar.cmd (revision 2508) +++ dllar.cmd (working copy) @@ -62,14 +62,18 @@ parse arg cmdLine; cmdLine = cmdLine||" "||value('DLLAR_CMDLINE',,'OS2ENVIRONMENT'); outFile = ''; + useDefFile = ''; inputFiles.0 = 0; description = ''; CC = 'gcc.exe'; - CFLAGS = '-s -Zcrtdll'; + CFLAGS = '-Zcrtdll'; EXTRA_CFLAGS = ''; EXPORT_BY_ORDINALS = 0; exclude_symbols = ''; library_flags = ''; + library_data = ''; + flag_omf = 0; + AR='ar' curDir = directory(); curDirS = curDir; if (right(curDirS, 1) \= '\') then @@ -85,6 +89,8 @@ i = i + 1; outFile = word(cmdLine, i); end; + when abbrev('def', substr(tmp, 2), 3) then + useDefFile = GetLongArg(); when abbrev('description', substr(tmp, 2), 1) then description = GetLongArg(); when abbrev('flags', substr(tmp, 2), 1) then @@ -99,10 +105,14 @@ exclude_symbols = exclude_symbols||GetLongArg()' '; when abbrev('libflags', substr(tmp, 2), 4) then library_flags = library_flags||GetLongArg()' '; + when abbrev('libdata', substr(tmp, 2), 4) then + library_data = library_data||GetLongArg()' '; when abbrev('nocrtdll', substr(tmp, 2), 5) then - CFLAGS = '-s'; + CFLAGS = ''; when abbrev('nolxlite', substr(tmp, 2), 5) then flag_USE_LXLITE = 0; + when abbrev('omf', substr(tmp, 2), 3) then + flag_omf = 1; otherwise EXTRA_CFLAGS = EXTRA_CFLAGS' 'tmp; end /*select*/ @@ -127,6 +137,12 @@ end; end; /* iterate cmdline words */ + if (flag_omf = 1) then + do + AR = 'emxomfar'; + CFLAGS = CFLAGS || ' -Zomf'; + end + /* check arg sanity */ if (inputFiles.0 = 0) then do @@ -153,7 +169,7 @@ /* Prefix with '!' to indicate archive */ inputFiles.I = '!'inputFiles.I; - call doCommand('cd 'substr(inputFiles.I, 2)' && ar x 'fullname); + call doCommand('cd 'substr(inputFiles.I, 2)' && 'AR' x 'fullname); call directory(curDir); rc = SysFileTree(substr(inputFiles.I, 2)'\*.o', 'files', 'FO'); if (rc = 0) then @@ -207,10 +223,13 @@ defFile = outFile'.def'; dllFile = outFile'.dll'; arcFile = outFile'.a'; + arcFileOmf = outFile'.lib'; if (do_backup & stream(arcFile, 'C', 'query exists') \= '') then call doCommand('ren 'arcFile' 'outFile'_s.a'); +if useDefFile = '' then +do /* * Extract public symbols from all the object files. */ @@ -227,6 +246,8 @@ call SysFileDelete(defFile); call stream defFile, 'c', 'open write'; call lineOut defFile, 'LIBRARY 'filespec('NAME', outFile)' 'library_flags; + if (length(library_data) > 0) then + call lineOut defFile, 'DATA 'library_data; if (length(description) > 0) then call lineOut defFile, 'DESCRIPTION "'description'"'; call lineOut defFile, 'EXPORTS'; @@ -256,7 +277,14 @@ call SysFileDelete(tmpdefFile); drop line ordinal tmpdefFile; /* try prevent running out of memory... */ +end +else do + defFile = useDefFile; + +end + + if 0 then do /* @@ -292,6 +320,7 @@ end call doCommand('emximp -o 'arcFile defFile); + call doCommand('emximp -o 'arcFileOmf defFile); if (flag_USE_LXLITE) then do add_flags = ''; @@ -313,12 +342,14 @@ say 'Usage: dllar [-o[utput] output_file] [-d[escription] "dll descrption"]' say ' [-cc "CC"] [-f[lags] "CFLAGS"] [-ord[inals]] -ex[clude] "symbol(s)"' say ' [-libf[lags] "{INIT|TERM}{GLOBAL|INSTANCE}"] [-nocrt[dll]]' + say ' [-libd[ata] "DATA"] [-omf]' + say ' [-nolxlite] [-def def_file]"' say ' [*.o] [*.a]' say '*> "output_file" should have no extension.' say ' If it has the .o, .a or .dll extension, it is automatically removed.' say ' The import library name is derived from this and is set to "name".a.' say '*> "cc" is used to use another GCC executable. (default: gcc.exe)' - say '*> "flags" should be any set of valid GCC flags. (default: -s -Zcrtdll)' + say '*> "flags" should be any set of valid GCC flags. (default: -Zcrtdll)' say ' These flags will be put at the start of GCC command line.' say '*> -ord[inals] tells dllar to export entries by ordinals. Be careful.' say '*> -ex[clude] defines symbols which will not be exported. You can define' @@ -327,8 +358,13 @@ say ' with the prefix before "*" will be exclude, (see _GLOBAL* above).' say '*> -libf[lags] can be used to add INITGLOBAL/INITINSTANCE and/or' say ' TERMGLOBAL/TERMINSTANCE flags to the dynamically-linked library.' + say '*> -libd[ata] can be used to add data segment attributes flags to the ' + say ' dynamically-linked library.' say '*> -nocrtdll switch will disable linking the library against emx''s' say ' C runtime DLLs.' + say '*> -nolxlite does not compress executable' + say '*> -def def_file do not generate .def file, use def_file instead.' + say '*> -omf will use OMF tools to extract the static library objects.' say '*> All other switches (for example -L./ or -lmylib) will be passed' say ' unchanged to GCC at the end of command line.' say '*> If you create a DLL from a library and you do not specify -o,'
comment:6 by , 18 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
comment:7 by , 18 years ago
Resolution: | fixed |
---|---|
Status: | closed → reopened |
It seems I missed a small change to code for dealing with *.obj files, deleting _s file, using level1 compression for lxlite exepack.
--- E:\rd\LibC\trunk\trunk\emx\src\misc\dllar.cmd Mon Apr 2 08:53:36 2007 +++ dllar.cmd Thu Jul 20 14:02:34 2006 @@ -171,12 +171,12 @@ inputFiles.I = '!'inputFiles.I; call doCommand('cd 'substr(inputFiles.I, 2)' && 'AR' x 'fullname); call directory(curDir); - rc = SysFileTree(substr(inputFiles.I, 2)'\*.o', 'files', 'FO'); + rc = SysFileTree(substr(inputFiles.I, 2)'\*.o*', 'files', 'FO'); if (rc = 0) then do inputFiles.0 = inputFiles.0 + 1; K = inputFiles.0; - inputFiles.K = substr(inputFiles.I, 2)'/*.o'; + inputFiles.K = substr(inputFiles.I, 2)'/*.o*'; /* Remove all empty files from archive since emxexp will barf */ do J = 1 to files.0 if (stream(files.J, 'C', 'QUERY SIZE') <= 32) then @@ -225,11 +225,13 @@ arcFile = outFile'.a'; arcFileOmf = outFile'.lib'; - if (do_backup & stream(arcFile, 'C', 'query exists') \= '') then + if (do_backup & stream(arcFile, 'C', 'query exists') \= '') then do + '@del 'outFile'_s.a > NUL'; call doCommand('ren 'arcFile' 'outFile'_s.a'); + end -if useDefFile = '' then -do +if useDefFile = '' then +do /* * Extract public symbols from all the object files. */ @@ -325,7 +328,7 @@ add_flags = ''; if (EXPORT_BY_ORDINALS) then add_flags = '-ynd'; - call doCommand('lxlite -cs -t: -mrn -mln 'add_flags' 'dllFile); + call doCommand('lxlite -cs -t: -mrn -ml1 'add_flags' 'dllFile); end; /*
comment:8 by , 18 years ago
Resolution: | → fixed |
---|---|
Status: | reopened → closed |
the diff file is inverted :-(
Also -s has been removed to allow using -g to produce debuggable libraries.