Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 13 Aug 2010 10:47:23 -0700
From:      Yuri <yuri@rawbw.com>
To:        Dan Nelson <dnelson@allantgroup.com>
Cc:        freebsd-questions@freebsd.org
Subject:   Re: Documentation on how to build 32bit applications on amd64?
Message-ID:  <4C65852B.807@rawbw.com>
In-Reply-To: <20100813162429.GE18896@dan.emsphone.com>
References:  <4C656E8F.8090105@rawbw.com> <20100813162429.GE18896@dan.emsphone.com>

next in thread | previous in thread | raw e-mail | index | archive | help
On 08/13/2010 09:24, Dan Nelson wrote:
> Try adding -B/usr/lib32 to your first gcc line.  The specs file should be
> modified to add this automatically when you pass -m32, imho.
>    

Thank you Dan, this flag worked.

But I found a strange discrepancy between 32bit and 64bit.
When I compile the program below in 64 bit, I get the correct result. 
With 32 bit executable compiled on 64 bit system like you suggested 
there is another (wrong) result. On 32 bit system result is also 
correct, the same as with 64 executable.

This is a very strange discrepancy. rm_eo field is zero in the match 
result which is wrong. I can't think of any explanation for it.

FreeBSD-8.1-STABLE

Yuri


--- program m.c ---
#include <regex.h>
#include <stdio.h>
#include <string.h>

void replace_all(char *str, char *pattern, char *replacement) {
   int res;
   int off = 0;
   regex_t re;
   regmatch_t match;

   res = regcomp(&re, pattern, REG_EXTENDED);
   while (off < (int)strlen(str) && regexec(&re, str+off, 1, &match, 
0)==0) {
     printf("match: off=%i so=%i eo=%i\n", off, (int)match.rm_so, 
(int)match.rm_eo);
     off += match.rm_eo;
   }
}

main() {
   replace_all("abc-def-fghijkl", "-", "_");
   return 0;
}

--- output of 64 bit executable (gcc -o m m.c) ---
match: off=0 so=3 eo=4
match: off=4 so=3 eo=4

--- output of 32 bit executable built on 64 bit system with flags (gcc 
-B/usr/lib32 -m32 -o m m.c) ---
match: off=0 so=3 eo=0




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?4C65852B.807>